X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/02aa6f67360bbd8f15c29fb0701badda99fc8c75..11bcbdb93e13e0b2c1625fc0f926378bce43fead:/apt-pkg/contrib/cdromutl.cc diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 83c324f54..187f6bd59 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -17,18 +19,19 @@ #include #include -#include - #include -#include #include #include #include #include #include #include + +#include /*}}}*/ +using std::string; + // IsMounted - Returns true if the mount point is mounted /*{{{*/ // --------------------------------------------------------------------- /* This is a simple algorithm that should always work, we stat the mount point @@ -206,8 +209,11 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) Hash.Add(Dir->d_name); }; - if (chdir(StartDir.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) { + _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + closedir(D); + return false; + } closedir(D); // Some stats from the fsys @@ -236,7 +242,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) } /*}}}*/ -// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ string FindMountPointForDevice(const char *devnode) { char buf[255]; @@ -254,7 +260,12 @@ string FindMountPointForDevice(const char *devnode) while ( fgets(buf, sizeof(buf), f) != NULL) { if (strncmp(buf, devnode, strlen(devnode)) == 0) { if(TokSplitString(' ', buf, out, 10)) - return string(out[1]); + { + fclose(f); + // unescape the \0XXX chars in the path + string mount_point = out[1]; + return DeEscapeString(mount_point); + } } } fclose(f); @@ -263,5 +274,4 @@ string FindMountPointForDevice(const char *devnode) return string(); } - - + /*}}}*/