49 #include <visp3/core/vpIoTools.h>
53 main(
int argc,
const char ** argv)
58 std::cout <<
"The directory separator character is '" << c <<
"' (Windows platform)." << std::endl;
61 std::cout <<
"The directory separator character is '" << c <<
"' (Unix like platform)." << std::endl;
65 std::string pathname =
"";
67 pathname =
"C:\\Program Files (x86)\\Java\\jre7";
69 pathname =
"/usr/bin/java";
73 std::cout <<
"Name of " << pathname <<
" is " <<
vpIoTools::getName(pathname) << std::endl;
76 if(argc == 3 && std::string(argv[1]) == std::string(
"-i"))
79 std::cout <<
"Name of " << argv[2] <<
" is " <<
vpIoTools::getName(argv[2]) << std::endl;
82 std::string windowsPathnameStyle =
"\\usr\\bin\\java";
83 std::cout <<
"Parent of " << windowsPathnameStyle <<
" is " <<
vpIoTools::getParent(windowsPathnameStyle) << std::endl;
84 std::cout <<
"Name of " << windowsPathnameStyle <<
" is " <<
vpIoTools::getName(windowsPathnameStyle) << std::endl;
86 std::string parent =
"/usr/toto/", child =
"\\blabla\\java";
88 std::cout <<
"Create file path from parent=" << parent <<
" and child=" << child <<
" is "
91 std::string expandPath =
"~/Documents/fictional directory/fictional file";
92 std::cout <<
"Path for " << expandPath <<
" is " <<
vpIoTools::path(expandPath) << std::endl;
94 std::cout <<
"Test get name with an empty pathname=" <<
vpIoTools::getName(
"") << std::endl;
97 expandPath =
"~/Documents/fictional dir/fictional file.txt";
98 std::cout <<
"Get name with a unix expand pathname " << expandPath <<
"=" <<
vpIoTools::getName(expandPath) << std::endl;
99 std::cout <<
"Get parent with a unix expand pathname " << expandPath <<
"=" <<
vpIoTools::getParent(expandPath) << std::endl;
107 pathname =
"c:/dir/fictional directory/fictional file.txt";
110 pathname =
"/home/user/Documents/fictional directory/fictional file.txt";
113 pathname =
"~/Documents/fictional directory/fictional file.txt";
116 pathname =
"fictional directory/fictional file.txt";
121 unsigned int nbFail = 0, nbOk = 0;
135 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"c:\\foo\\bar").second <<
" should be=\\foo\\bar" << std::endl;
150 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"c:/foo/bar").second <<
" should be=/foo/bar" << std::endl;
153 if(strcmp(
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").first.c_str(),
"\\\\conky\\mountpoint") == 0) {
158 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").first <<
" should be=\\\\conky\\mountpoint" << std::endl;
160 if(strcmp(
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").second.c_str(),
"\\foo\\bar") == 0) {
165 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\mountpoint\\foo\\bar").second <<
" should be=\\foo\\bar" << std::endl;
168 if(strcmp(
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").first.c_str(),
"//conky/mountpoint") == 0) {
173 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").first <<
" should be=//conky/mountpoint" << std::endl;
180 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky/mountpoint/foo/bar").second <<
" should be=/foo/bar" << std::endl;
188 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\\\conky\\mountpoint\\foo\\bar").first <<
" should be=" << std::endl;
191 "\\\\\\conky\\mountpoint\\foo\\bar") == 0) {
196 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\\\conky\\mountpoint\\foo\\bar").second <<
" should be=\\\\\\conky\\mountpoint\\foo\\bar" << std::endl;
204 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").first <<
" should be=" << std::endl;
206 if(strcmp(
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").second.c_str(),
"///conky/mountpoint/foo/bar") == 0) {
211 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"///conky/mountpoint/foo/bar").second <<
" should be=///conky/mountpoint/foo/bar" << std::endl;
219 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\\\mountpoint\\foo\\bar").first <<
" should be=" << std::endl;
222 "\\\\conky\\\\mountpoint\\foo\\bar") == 0) {
227 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"\\\\conky\\\\mountpoint\\foo\\bar").second <<
" should be=\\\\conky\\\\mountpoint\\foo\\bar" << std::endl;
235 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").first <<
" should be=" << std::endl;
237 if(strcmp(
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").second.c_str(),
"//conky//mountpoint/foo/bar") == 0) {
242 std::cout <<
"Fail=" <<
vpIoTools::splitDrive(
"//conky//mountpoint/foo/bar").second <<
" should be=//conky//mountpoint/foo/bar" << std::endl;
245 std::cout <<
"Test vpIoTools::splitDrive (Win32) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
334 std::cout <<
"Test vpIoTools::getFileExtension (WIN32 platform) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
435 std::cout <<
"Test vpIoTools::getFileExtension (Unix-like platform) - passed: " << nbOk <<
"/" << (nbOk+nbFail) << std::endl;
439 std::cout << std::endl <<
"End" << std::endl;