Skip to content

Instantly share code, notes, and snippets.

@dot
Created September 7, 2011 08:28
Show Gist options
  • Save dot/1200053 to your computer and use it in GitHub Desktop.
Save dot/1200053 to your computer and use it in GitHub Desktop.
test for chdir & Poco::Path
#include <Poco/Path.h>
#include <Poco/Format.h>
#include <iostream>
#include <unistd.h>
int main(int argc, char** argv) {
std::cout << Poco::format(" current() (Current directory): %s", Poco::Path::current()) << std::endl;
Poco::Path p(Poco::Path::current());
std::cout << Poco::format(" .. : %s", p.forDirectory("..").absolute().toString()) << std::endl;
if (argc == 2) {
if (chdir(argv[1]) == 0) {
std::cout << Poco::format(" current() (Current directory): %s", Poco::Path::current()) << std::endl;
} else {
std::cout << "cannot move to " << argv[1] << std::endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment