53 #include <visp/vpIoTools.h>
57 main(
int argc,
const char ** argv)
62 std::cout <<
"The directory separator character is '" << c <<
"' (Windows platform)." << std::endl;
65 std::cout <<
"The directory separator character is '" << c <<
"' (Unix like platform)." << std::endl;
69 std::string pathname =
"";
71 pathname =
"C:\\Program Files (x86)\\Java\\jre7";
73 pathname =
"/usr/bin/java";
77 std::cout <<
"Name of " << pathname <<
" is " <<
vpIoTools::getName(pathname) << std::endl;
80 if(argc == 3 && std::string(argv[1]) == std::string(
"-i"))
83 std::cout <<
"Name of " << argv[2] <<
" is " <<
vpIoTools::getName(argv[2]) << std::endl;
86 std::string windowsPathnameStyle =
"\\usr\\bin\\java";
87 std::cout <<
"Parent of " << windowsPathnameStyle <<
" is " <<
vpIoTools::getParent(windowsPathnameStyle) << std::endl;
88 std::cout <<
"Name of " << windowsPathnameStyle <<
" is " <<
vpIoTools::getName(windowsPathnameStyle) << std::endl;
90 std::string parent =
"/usr/toto/", child =
"\\blabla\\java";
92 std::cout <<
"Create file path from parent=" << parent <<
" and child=" << child <<
" is "
95 std::string expandPath =
"~/Documents/fictional directory/fictional file";
96 std::cout <<
"Path for " << expandPath <<
" is " <<
vpIoTools::path(expandPath) << std::endl;
98 std::cout <<
"Test get name with an empty pathname=" <<
vpIoTools::getName(
"") << std::endl;
101 expandPath =
"~/Documents/fictional dir/fictional file.txt";
102 std::cout <<
"Get name with a unix expand pathname " << expandPath <<
"=" <<
vpIoTools::getName(expandPath) << std::endl;
103 std::cout <<
"Get parent with a unix expand pathname " << expandPath <<
"=" <<
vpIoTools::getParent(expandPath) << std::endl;
111 pathname =
"c:/dir/fictional directory/fictional file.txt";
114 pathname =
"/home/user/Documents/fictional directory/fictional file.txt";
117 pathname =
"~/Documents/fictional directory/fictional file.txt";
120 pathname =
"fictional directory/fictional file.txt";
125 unsigned int nbFail = 0, nbOk = 0;
139 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"c:\\foo\\bar").second <<
" should be=\\foo\\bar" << std::endl;
154 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"c:/foo/bar").second <<
" should be=/foo/bar" << std::endl;
157 if(strcmp(
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").first.c_str(),
"\\\\conky\\mountpoint") == 0) {
162 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").first <<
" should be=\\\\conky\\mountpoint" << std::endl;
164 if(strcmp(
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").second.c_str(),
"\\foo\\bar") == 0) {
169 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").second <<
" should be=\\foo\\bar" << std::endl;
172 if(strcmp(
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").first.c_str(),
"//conky/mountpoint") == 0) {
177 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").first <<
" should be=//conky/mountpoint" << std::endl;
184 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").second <<
" should be=/foo/bar" << std::endl;
192 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\\\conky\\mountpoint\\foo\\bar").first <<
" should be=" << std::endl;
195 "\\\\\\conky\\mountpoint\\foo\\bar") == 0) {
200 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\\\conky\\mountpoint\\foo\\bar").second <<
" should be=\\\\\\conky\\mountpoint\\foo\\bar" << std::endl;
208 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").first <<
" should be=" << std::endl;
210 if(strcmp(
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").second.c_str(),
"///conky/mountpoint/foo/bar") == 0) {
215 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").second <<
" should be=///conky/mountpoint/foo/bar" << std::endl;
223 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\\\mountpoint\\foo\\bar").first <<
" should be=" << std::endl;
226 "\\\\conky\\\\mountpoint\\foo\\bar") == 0) {
231 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\\\mountpoint\\foo\\bar").second <<
" should be=\\\\conky\\\\mountpoint\\foo\\bar" << std::endl;
239 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").first <<
" should be=" << std::endl;
241 if(strcmp(
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").second.c_str(),
"//conky//mountpoint/foo/bar") == 0) {
246 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").second <<
" should be=//conky//mountpoint/foo/bar" << std::endl;
249 std::cout <<
"Test vpIoTools::splitDrive (Win32) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
338 std::cout <<
"Test vpIoTools::getFileExtension (WIN32 platform) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
439 std::cout <<
"Test vpIoTools::getFileExtension (Unix-like platform) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
443 std::cout << std::endl <<
"End" << std::endl;