19   static char buf[512] = {0};
 
   22      char pathbuffer[_MAX_PATH] = {0};
 
   24      _searchenv( 
"cygpath.exe", 
"PATH", pathbuffer );
 
   25      if( *pathbuffer == 
'\0' ) {
 
   26         sprintf(buf, 
"%c:", _getdrive());
 
   29      FILE *pipe = _popen( 
"cygpath -m /", 
"rt" );
 
   32      fgets(buf, 
sizeof(buf), pipe);
 
   33      int len = strlen(buf);
 
   34      while (buf[len - 1] == 
'\n' || buf[len - 1] == 
'\r') {
 
   37      if (!feof(pipe)) _pclose(pipe);
 
   38      else fprintf(stderr, 
"GetCygwinRootDir() error: Failed to read the pipe to the end.\n");
 
   46   static std::string cygRoot;
 
   47   size_t posCygDrive = path.find(
"/cygdrive/");
 
   48   if (posCygDrive != std::string::npos) {
 
   49      path[posCygDrive] = path[posCygDrive + 10];
 
   50      path[posCygDrive + 1] = 
':';
 
   51      path.erase(posCygDrive + 2, 9);
 
   54      size_t posHome = path.find(
"/home/");
 
   55      if (posHome != std::string::npos) {
 
   56         size_t posColumn = path.find(
":");
 
   57         if (posColumn != std::string::npos && posColumn > 0) {
 
   59            if (path[posColumn - 1] >= 
'A' && path[posColumn - 1] <= 
'Z')
 
   61            if (path[posColumn - 1] >= 
'a' && path[posColumn - 1] <= 
'z')
 
   64         if (cygRoot.empty()) {
 
   66            size_t len = cygRoot.length();
 
   67            if (cygRoot[len - 1] == 
'/') {
 
   68               cygRoot.erase(len - 1);
 
   71         path.insert(posHome, cygRoot);
 
static bool FromCygToNativePath(std::string &path)
 
static const char * GetCygwinRootDir()