[haiku-commits] r35173 - haiku/trunk/src/apps/installer

Author: stippi
Date: 2010-01-19 19:51:30 +0100 (Tue, 19 Jan 2010)
New Revision: 35173
Changeset: http://dev.haiku-os.org/changeset/35173/haiku

Modified:
   haiku/trunk/src/apps/installer/CopyEngine.cpp
   haiku/trunk/src/apps/installer/CopyEngine.h
Log:
Make the Installer ignore /var at it's new location. The old location is also
still checked, in case one uses the Installer to copy an old installation.


Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp
===================================================================
--- haiku/trunk/src/apps/installer/CopyEngine.cpp       2010-01-19 18:25:48 UTC 
(rev 35172)
+++ haiku/trunk/src/apps/installer/CopyEngine.cpp       2010-01-19 18:51:30 UTC 
(rev 35173)
@@ -13,6 +13,7 @@
 #include <sys/resource.h>
 
 #include <Directory.h>
+#include <FindDirectory.h>
 #include <fs_attr.h>
 #include <NodeInfo.h>
 #include <Path.h>
@@ -62,6 +63,11 @@
        rl.rlim_cur = 512;
        rl.rlim_max = RLIM_SAVED_MAX;
        setrlimit(RLIMIT_NOFILE, &rl);
+
+       // init BEntry pointing to /var
+       BPath path;
+       if (find_directory(B_COMMON_VAR_DIRECTORY, &path) == B_OK)
+               fVarDirectory.SetTo(path.Path());
 }
 
 
@@ -231,7 +237,7 @@
                if (ret < B_OK)
                        return ret;
 
-               if (!_ShouldCopyEntry(name, statInfo, level))
+               if (!_ShouldCopyEntry(entry, name, statInfo, level))
                        continue;
 
                if (S_ISDIR(statInfo.st_mode)) {
@@ -302,7 +308,7 @@
                struct stat statInfo;
                entry.GetStat(&statInfo);
 
-               if (!_ShouldCopyEntry(name, statInfo, level))
+               if (!_ShouldCopyEntry(entry, name, statInfo, level))
                        continue;
 
                fItemsCopied++;
@@ -490,11 +496,12 @@
 
 
 bool
-CopyEngine::_ShouldCopyEntry(const char* name, const struct stat& statInfo,
-       int32 level) const
+CopyEngine::_ShouldCopyEntry(const BEntry& entry, const char* name,
+       const struct stat& statInfo, int32 level) const
 {
        if (level == 1 && S_ISDIR(statInfo.st_mode)) {
                if (strcmp(VAR_DIRECTORY, name) == 0) {
+                       // old location of /boot/var
                        printf("ignoring '%s'.\n", name);
                        return false;
                }
@@ -517,6 +524,11 @@
                        return false;
                }
        }
+       if (fVarDirectory == entry) {
+               // current location of var
+               printf("ignoring '%s'.\n", name);
+               return false;
+       }
        return true;
 }
 

Modified: haiku/trunk/src/apps/installer/CopyEngine.h
===================================================================
--- haiku/trunk/src/apps/installer/CopyEngine.h 2010-01-19 18:25:48 UTC (rev 
35172)
+++ haiku/trunk/src/apps/installer/CopyEngine.h 2010-01-19 18:51:30 UTC (rev 
35173)
@@ -42,7 +42,8 @@
                                                                        const 
char* destination,
                                                                        int32& 
level, sem_id cancelSemaphore);
 
-                       bool                            _ShouldCopyEntry(const 
char* name,
+                       bool                            _ShouldCopyEntry(const 
BEntry& entry,
+                                                                       const 
char* name,
                                                                        const 
struct stat& statInfo,
                                                                        int32 
level) const;
 
@@ -106,6 +107,9 @@
                        const char*                     fCurrentItem;
 
                        ProgressReporter*       fProgressReporter;
+
+       // TODO: Should be made into a list of BEntris to be ignored, perhaps.
+                       BEntry                          fVarDirectory;
 };
 
 


Other related posts: