[cmake-commits] king committed SystemTools.cxx 1.197 1.198 SystemTools.hxx.in 1.64 1.65

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Mar 12 12:50:30 EST 2007


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv12235/kwsys

Modified Files:
	SystemTools.cxx SystemTools.hxx.in 
Log Message:
ENH: Added kwsys SystemTools::CreateSymlink and SystemTools::ReadSymlink.


Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- SystemTools.cxx	2 Mar 2007 15:48:35 -0000	1.197
+++ SystemTools.cxx	12 Mar 2007 17:50:28 -0000	1.198
@@ -2356,6 +2356,44 @@
 #endif
 }
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+bool SystemTools::CreateSymlink(const char*, const char*)
+{
+  return false;
+}
+#else
+bool SystemTools::CreateSymlink(const char* origName, const char* newName)
+{
+  return symlink(origName, newName) >= 0;
+}
+#endif
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+bool SystemTools::ReadSymlink(const char*, kwsys_stl::string&)
+{
+  return false;
+}
+#else
+bool SystemTools::ReadSymlink(const char* newName,
+                              kwsys_stl::string& origName)
+{
+  char buf[KWSYS_SYSTEMTOOLS_MAXPATH+1];
+  int count =
+    static_cast<int>(readlink(newName, buf, KWSYS_SYSTEMTOOLS_MAXPATH));
+  if(count >= 0)
+    {
+    // Add null-terminator.
+    buf[count] = 0;
+    origName = buf;
+    return true;
+    }
+  else
+    {
+    return false;
+    }
+}
+#endif
+
 int SystemTools::ChangeDirectory(const char *dir)
 {
   return Chdir(dir);

Index: SystemTools.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.hxx.in,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- SystemTools.hxx.in	1 Mar 2007 19:30:42 -0000	1.64
+++ SystemTools.hxx.in	12 Mar 2007 17:50:28 -0000	1.65
@@ -589,6 +589,18 @@
     double percent_bin = 0.05);
 
   /**
+   * Create a symbolic link if the platform supports it.  Returns whether
+   * creation succeded.
+   */
+  static bool CreateSymlink(const char* origName, const char* newName);
+
+  /**
+   * Read the contents of a symbolic link.  Returns whether reading
+   * succeded.
+   */
+  static bool ReadSymlink(const char* newName, kwsys_stl::string& origName);
+
+  /**
    * Try to locate the file 'filename' in the directory 'dir'.
    * If 'filename' is a fully qualified filename, the basename of the file is
    * used to check for its existence in 'dir'.



More information about the Cmake-commits mailing list