Hi list,

Ive created a patch for cxxtools enhancing the filetest-function with
symlinks. If you find it useful, feel free to integrate it in cxxtools! :-)

Regards,
Oliver

diff -upr cxxtools-2.1.1/include/cxxtools/fileinfo.h cxxtools-2.1.1-symlink/include/cxxtools/fileinfo.h
--- cxxtools-2.1.1/include/cxxtools/fileinfo.h	2012-05-03 18:05:42.000000000 +0200
+++ cxxtools-2.1.1-symlink/include/cxxtools/fileinfo.h	2012-11-08 21:40:30.055824873 +0100
@@ -42,7 +42,8 @@ class FileInfo
         {
             Invalid = 0,
             Directory = 1,
-            File = 2
+            File = 2,
+            Link = 3 
         };
 
     public:
@@ -87,6 +88,9 @@ class FileInfo
         //! @brief Returns the size of the file in bytes
         std::size_t size() const;
 
+        //! @brief Returns true if the node is a Symlink
+        bool isLink() const;
+
         //! @brief Returns true if the node is a directory
         bool isDirectory() const;
 
diff -upr cxxtools-2.1.1/src/fileinfo.cpp cxxtools-2.1.1-symlink/src/fileinfo.cpp
--- cxxtools-2.1.1/src/fileinfo.cpp	2012-05-03 18:06:16.000000000 +0200
+++ cxxtools-2.1.1-symlink/src/fileinfo.cpp	2012-11-08 21:57:31.773111807 +0100
@@ -128,6 +128,11 @@ bool FileInfo::isDirectory() const
     return _type == FileInfo::Directory;
 }
 
+bool FileInfo::isLink() const
+{
+    return _type == FileInfo::Link;
+}
+
 
 bool FileInfo::isFile() const
 {
diff -upr cxxtools-2.1.1/src/fileinfoimpl.h cxxtools-2.1.1-symlink/src/fileinfoimpl.h
--- cxxtools-2.1.1/src/fileinfoimpl.h	2012-05-03 18:06:16.000000000 +0200
+++ cxxtools-2.1.1-symlink/src/fileinfoimpl.h	2012-11-08 21:35:00.626135846 +0100
@@ -53,6 +53,11 @@ namespace cxxtools {
                 {
                     return FileInfo::Directory;
                 }
+                else if( S_ISLNK(st.st_mode) ) 
+                {
+                    return FileInfo::Link;
+                }
+                
 
                 return FileInfo::File;
             }
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to