2005-05-15 02:50:07 +00:00
|
|
|
//This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
//Copyright (C) 2004-2005 James Turk
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// James Turk (jpt2433@rit.edu)
|
|
|
|
//
|
|
|
|
// Version:
|
2005-08-08 04:55:48 +00:00
|
|
|
// $Id: filesys_test.cpp,v 1.4 2005/08/08 04:55:48 cozman Exp $
|
2005-05-15 02:50:07 +00:00
|
|
|
|
|
|
|
#include "photon.hpp"
|
2005-07-06 02:10:06 +00:00
|
|
|
#include <iostream>
|
2005-05-15 02:50:07 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace photon;
|
|
|
|
using namespace photon::util;
|
|
|
|
|
2005-07-20 01:43:57 +00:00
|
|
|
// Basic test of util::filesys functionality, simply outputs essentially
|
|
|
|
// all information available via util::filesys.
|
2005-08-08 04:55:48 +00:00
|
|
|
int PhotonMain(const StrVec& args)
|
2005-05-15 02:50:07 +00:00
|
|
|
{
|
2005-08-08 04:55:48 +00:00
|
|
|
StrVec list;
|
|
|
|
|
|
|
|
//System Directories
|
|
|
|
|
|
|
|
list = filesys::getCDDirs();
|
|
|
|
cout << "CD directories: ";
|
|
|
|
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
|
2005-05-15 02:50:07 +00:00
|
|
|
{
|
2005-08-08 04:55:48 +00:00
|
|
|
cout << *i << " ";
|
2005-05-15 02:50:07 +00:00
|
|
|
}
|
2005-08-08 04:55:48 +00:00
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
cout << "Base Directory: " << filesys::getBaseDir() << endl;
|
|
|
|
cout << "User Directory: " << filesys::getUserDir() << endl;
|
|
|
|
|
|
|
|
//Search Path
|
|
|
|
|
|
|
|
cout << "adding base directory to search & write path" << endl;
|
|
|
|
filesys::addToSearchPath( filesys::getBaseDir(), false );
|
|
|
|
filesys::setWriteDir( filesys::getBaseDir() );
|
|
|
|
|
|
|
|
list = filesys::getSearchPath();
|
|
|
|
cout << "Search path: ";
|
|
|
|
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
|
|
|
|
{
|
|
|
|
cout << *i << " ";
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
// Searching & Manipulation
|
|
|
|
|
|
|
|
list = filesys::listDir("/");
|
|
|
|
cout << "base dir contents: ";
|
|
|
|
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
|
|
|
|
{
|
|
|
|
cout << *i << " ";
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
cout << "filesys_test.cpp"
|
|
|
|
<< (filesys::exists("filesys_test.cpp") ? " exists" : " not found")
|
|
|
|
<< endl;
|
|
|
|
cout << "wokka "
|
|
|
|
<< (filesys::exists("wokka") ? " exists" : " not found") << endl;
|
|
|
|
|
|
|
|
cout << "making directory 'bam'" << endl;
|
|
|
|
filesys::mkdir("bam");
|
|
|
|
|
|
|
|
cout << "bam " << (filesys::isDir("bam") ? " is dir" : " not dir")
|
|
|
|
<< endl;
|
|
|
|
cout << "filesys_test.cpp"
|
|
|
|
<< (filesys::isDir("filesys_test.cpp") ? " is dir" : " not dir")
|
|
|
|
<< endl;
|
|
|
|
|
|
|
|
filesys::remove("bam");
|
|
|
|
cout << "removing directory 'bam'" << endl;
|
|
|
|
|
|
|
|
//other
|
|
|
|
|
|
|
|
cout << "Dir separator: " << filesys::getDirSeparator() << endl;
|
|
|
|
cout << "Mod time of filesys_test.cpp" ": "
|
|
|
|
<< filesys::getModTime("filesys_test.cpp") << endl;
|
|
|
|
|
|
|
|
// search path redux
|
|
|
|
|
|
|
|
cout << "removing base directory from search/write path" << endl;
|
|
|
|
filesys::removeFromSearchPath( filesys::getBaseDir() );
|
|
|
|
filesys::setWriteDir( std::string() );
|
|
|
|
|
|
|
|
list = filesys::getSearchPath();
|
|
|
|
cout << "Search path: ";
|
|
|
|
for(vector<string>::iterator i=list.begin(); i != list.end(); ++i)
|
|
|
|
{
|
|
|
|
cout << *i << " ";
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-05-15 02:50:07 +00:00
|
|
|
|