SHARE
TWEET

Untitled

a guest Feb 21st, 2012 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <direct.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. /*
  6.         compile with
  7.         g++ test_chdir.cpp -o test_chdir.exe
  8. */
  9.  
  10. void verbose_chdir(const char* path){
  11.         const int err = _chdir(path);
  12.         printf("chdir %s\n", path);
  13.         if (err == 0)
  14.                 return;
  15.         switch (errno) {
  16.         case ENOENT:
  17.                 printf( "Unable to locate the directory: %s\n", path );
  18.                 break;
  19.         case EINVAL:
  20.                 printf( "Invalid buffer.\n");
  21.                 break;
  22.         default:
  23.                 printf( "Unknown error.\n");
  24.         }
  25. }
  26.  
  27. int main(int argc, char**argv){
  28.         verbose_chdir("C:\\Reactos\\");
  29.         verbose_chdir("C:\\Reactos\\");
  30.  
  31.         verbose_chdir("C:\\Reactos");
  32.         verbose_chdir("C:\\Reactos");
  33.  
  34.         return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top