Changeset 2992
- Timestamp:
- 28/08/2011 20:07:17 (9 months ago)
- Location:
- box/trunk
- Files:
-
- 6 edited
-
bin/bbackupd/BackupClientDirectoryRecord.cpp (modified) (24 diffs)
-
bin/bbackupd/BackupClientDirectoryRecord.h (modified) (5 diffs)
-
bin/bbackupd/BackupDaemon.cpp (modified) (2 diffs)
-
bin/bbackupd/BackupDaemon.h (modified) (1 diff)
-
lib/win32/emu.cpp (modified) (6 diffs)
-
lib/win32/emu.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
r2983 r2992 19 19 20 20 #include "autogen_BackupProtocol.h" 21 #include "autogen_ClientException.h" 21 22 #include "Archive.h" 22 23 #include "BackupClientContext.h" … … 102 103 } 103 104 105 std::string BackupClientDirectoryRecord::ConvertVssPathToRealPath( 106 const std::string &rVssPath, 107 const Location& rBackupLocation) 108 { 109 #ifdef ENABLE_VSS 110 if (rBackupLocation.mIsSnapshotCreated && 111 rVssPath.substr(0, rBackupLocation.mSnapshotPath.length()) == 112 rBackupLocation.mSnapshotPath) 113 { 114 return rBackupLocation.mPath + 115 rVssPath.substr(rBackupLocation.mSnapshotPath.length()); 116 } 117 #endif 118 119 return rVssPath; 120 } 121 104 122 // -------------------------------------------------------------------------- 105 123 // … … 119 137 const std::string &rLocalPath, 120 138 const std::string &rRemotePath, 139 const Location& rBackupLocation, 121 140 bool ThisDirHasJustBeenCreated) 122 141 { … … 164 183 // deletion will be noticed, deleted from server, 165 184 // and this object deleted. 166 rNotifier.NotifyDirStatFailed(this, rLocalPath, 185 rNotifier.NotifyDirStatFailed(this, 186 ConvertVssPathToRealPath(rLocalPath, rBackupLocation), 167 187 strerror(errno)); 168 188 return; … … 213 233 // Report the error (logs and 214 234 // eventual email to administrator) 215 rNotifier.NotifyFileStatFailed(this, rLocalPath, 235 rNotifier.NotifyFileStatFailed(this, 236 ConvertVssPathToRealPath(rLocalPath, rBackupLocation), 216 237 strerror(errno)); 217 238 218 239 // FIXME move to NotifyFileStatFailed() 219 SetErrorWhenReadingFilesystemObject(rParams, 220 rLocalPath.c_str()); 240 SetErrorWhenReadingFilesystemObject(rParams, rLocalPath); 221 241 222 242 // This shouldn't happen, so we'd better not continue … … 230 250 try 231 251 { 232 rNotifier.NotifyScanDirectory(this, rLocalPath); 252 rNotifier.NotifyScanDirectory(this, 253 ConvertVssPathToRealPath(rLocalPath, rBackupLocation)); 233 254 234 255 dirHandle = ::opendir(rLocalPath.c_str()); … … 240 261 { 241 262 rNotifier.NotifyDirListFailed(this, 242 rLocalPath, "Access denied"); 263 ConvertVssPathToRealPath(rLocalPath, rBackupLocation), 264 "Access denied"); 243 265 } 244 266 else 245 267 { 246 268 rNotifier.NotifyDirListFailed(this, 247 rLocalPath, strerror(errno)); 269 ConvertVssPathToRealPath(rLocalPath, rBackupLocation), 270 strerror(errno)); 248 271 } 249 272 250 273 // Report the error (logs and eventual email 251 274 // to administrator) 252 SetErrorWhenReadingFilesystemObject(rParams, 253 rLocalPath.c_str()); 275 SetErrorWhenReadingFilesystemObject(rParams, rLocalPath); 254 276 // Ignore this directory for now. 255 277 return; … … 298 320 // which would normally contain DT_REG, 299 321 // DT_DIR, etc, but we only use it here and 300 // prefer S_IFREG, S_IFDIR... 301 int type = en->d_type; 302 #else 322 // prefer to have the full file attributes. 323 int type; 324 if (en->d_type & FILE_ATTRIBUTE_DIRECTORY) 325 { 326 type = S_IFDIR; 327 } 328 else 329 { 330 type = S_IFREG; 331 } 332 333 #else // !WIN32 334 303 335 if(EMU_LSTAT(filename.c_str(), &file_st) != 0) 304 336 { … … 315 347 // FIXME move to 316 348 // NotifyFileStatFailed() 317 SetErrorWhenReadingFilesystemObject( 318 rParams, filename.c_str()); 349 SetErrorWhenReadingFilesystemObject(rParams, filename); 319 350 } 320 351 … … 348 379 mSuppressMultipleLinksWarning = true; 349 380 } 350 SetErrorWhenReadingFilesystemObject( 351 rParams, filename.c_str()); 381 SetErrorWhenReadingFilesystemObject(rParams, filename); 352 382 } 353 383 … … 381 411 if(rParams.mrContext.ExcludeFile(filename)) 382 412 { 383 rNotifier.NotifyFileExcluded( 384 this, 385 filename); 413 rNotifier.NotifyFileExcluded(this, 414 ConvertVssPathToRealPath(filename, rBackupLocation)); 386 415 387 416 // Next item! … … 399 428 if(rParams.mrContext.ExcludeDir(filename)) 400 429 { 401 rNotifier.NotifyDirExcluded( 402 this, 403 filename); 430 rNotifier.NotifyDirExcluded(this, 431 ConvertVssPathToRealPath(filename, rBackupLocation)); 404 432 405 433 // Next item! 406 434 continue; 407 435 } 436 437 #ifdef WIN32 438 // exclude reparse points, as Application Data points to the 439 // parent directory under Vista and later, and causes an 440 // infinite loop: 441 // http://social.msdn.microsoft.com/forums/en-US/windowscompatibility/thread/05d14368-25dd-41c8-bdba-5590bf762a68/ 442 if (en->d_type & FILE_ATTRIBUTE_REPARSE_POINT) 443 { 444 rNotifier.NotifyMountPointSkipped(this, 445 ConvertVssPathToRealPath(filename, rBackupLocation)); 446 continue; 447 } 448 #endif 408 449 409 450 // Store on list … … 423 464 else if(rParams.mrContext.ExcludeFile(filename)) 424 465 { 425 rNotifier.NotifyFileExcluded( 426 this, 427 filename); 466 rNotifier.NotifyFileExcluded(this, 467 ConvertVssPathToRealPath(filename, rBackupLocation)); 428 468 } 429 469 else 430 470 { 431 rNotifier.NotifyUnsupportedFileType( 432 this, filename);433 SetErrorWhenReadingFilesystemObject( 434 rParams, filename.c_str());471 rNotifier.NotifyUnsupportedFileType(this, 472 ConvertVssPathToRealPath(filename, rBackupLocation)); 473 SetErrorWhenReadingFilesystemObject(rParams, 474 ConvertVssPathToRealPath(filename, rBackupLocation)); 435 475 } 436 476 … … 447 487 { 448 488 rNotifier.NotifyFileStatFailed(this, 449 filename, 489 ConvertVssPathToRealPath(filename, rBackupLocation), 450 490 strerror(errno)); 451 491 452 492 // Report the error (logs and 453 493 // eventual email to administrator) 454 SetErrorWhenReadingFilesystemObject( 455 rParams, filename.c_str()); 494 SetErrorWhenReadingFilesystemObject(rParams, filename); 456 495 457 496 // Ignore this entry for now. … … 462 501 { 463 502 rNotifier.NotifyMountPointSkipped(this, 464 filename);503 ConvertVssPathToRealPath(filename, rBackupLocation)); 465 504 continue; 466 505 } … … 482 521 if(!rParams.mHaveLoggedWarningAboutFutureFileTimes) 483 522 { 484 rNotifier.NotifyFileModifiedInFuture( 485 this, filename);523 rNotifier.NotifyFileModifiedInFuture(this, 524 ConvertVssPathToRealPath(filename, rBackupLocation)); 486 525 rParams.mHaveLoggedWarningAboutFutureFileTimes = true; 487 526 } … … 557 596 // Do the directory reading 558 597 bool updateCompleteSuccess = UpdateItems(rParams, rLocalPath, 559 rRemotePath, pdirOnStore, entriesLeftOver, files, dirs);598 rRemotePath, rBackupLocation, pdirOnStore, entriesLeftOver, files, dirs); 560 599 561 600 // LAST THING! (think exception safety) … … 700 739 const std::string &rLocalPath, 701 740 const std::string &rRemotePath, 741 const Location& rBackupLocation, 702 742 BackupStoreDirectory *pDirOnStore, 703 743 std::vector<BackupStoreDirectory::Entry *> &rEntriesLeftOver, … … 755 795 // Report the error (logs and 756 796 // eventual email to administrator) 757 SetErrorWhenReadingFilesystemObject(rParams, 758 filename.c_str()); 797 SetErrorWhenReadingFilesystemObject(rParams, filename); 759 798 760 799 // Ignore this entry for now. … … 1061 1100 allUpdatedSuccessfully = false; 1062 1101 // Log it. 1063 SetErrorWhenReadingFilesystemObject(rParams, filename.c_str()); 1064 rNotifier.NotifyFileUploadException( 1065 this, filename, e); 1102 SetErrorWhenReadingFilesystemObject(rParams, filename); 1103 rNotifier.NotifyFileUploadException(this, filename, e); 1066 1104 } 1067 1105 … … 1082 1120 { 1083 1121 rNotifier.NotifyFileSkippedServerFull(this, 1084 filename);1122 ConvertVssPathToRealPath(filename, rBackupLocation)); 1085 1123 } 1086 1124 } … … 1421 1459 { 1422 1460 // Sync this sub directory too 1423 psubDirRecord->SyncDirectory(rParams, mObjectID, 1424 dirname, rRemotePath + "/" + *d,1461 psubDirRecord->SyncDirectory(rParams, mObjectID, dirname, 1462 rRemotePath + "/" + *d, rBackupLocation, 1425 1463 haveJustCreatedDirOnServer); 1426 1464 } … … 1732 1770 // 1733 1771 // -------------------------------------------------------------------------- 1734 void BackupClientDirectoryRecord::SetErrorWhenReadingFilesystemObject(BackupClientDirectoryRecord::SyncParams &rParams, const char *Filename) 1772 void BackupClientDirectoryRecord::SetErrorWhenReadingFilesystemObject( 1773 BackupClientDirectoryRecord::SyncParams &rParams, 1774 const std::string& rFilename) 1735 1775 { 1736 1776 // Zero hash, so it gets synced properly next time round. … … 1966 2006 } 1967 2007 } 2008 2009 // -------------------------------------------------------------------------- 2010 // 2011 // Function 2012 // Name: Location::Location() 2013 // Purpose: Constructor 2014 // Created: 11/11/03 2015 // 2016 // -------------------------------------------------------------------------- 2017 Location::Location() 2018 : mIDMapIndex(0), 2019 mpExcludeFiles(0), 2020 mpExcludeDirs(0) 2021 { 2022 } 2023 2024 // -------------------------------------------------------------------------- 2025 // 2026 // Function 2027 // Name: Location::~Location() 2028 // Purpose: Destructor 2029 // Created: 11/11/03 2030 // 2031 // -------------------------------------------------------------------------- 2032 Location::~Location() 2033 { 2034 // Clean up exclude locations 2035 if(mpExcludeDirs != 0) 2036 { 2037 delete mpExcludeDirs; 2038 mpExcludeDirs = 0; 2039 } 2040 if(mpExcludeFiles != 0) 2041 { 2042 delete mpExcludeFiles; 2043 mpExcludeFiles = 0; 2044 } 2045 } 2046 2047 // -------------------------------------------------------------------------- 2048 // 2049 // Function 2050 // Name: Location::Serialize(Archive & rArchive) 2051 // Purpose: Serializes this object instance into a stream of bytes, 2052 // using an Archive abstraction. 2053 // 2054 // Created: 2005/04/11 2055 // 2056 // -------------------------------------------------------------------------- 2057 void Location::Serialize(Archive & rArchive) const 2058 { 2059 // 2060 // 2061 // 2062 rArchive.Write(mName); 2063 rArchive.Write(mPath); 2064 rArchive.Write(mIDMapIndex); 2065 2066 // 2067 // 2068 // 2069 if(mpDirectoryRecord.get() == NULL) 2070 { 2071 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP; 2072 rArchive.Write(aMagicMarker); 2073 } 2074 else 2075 { 2076 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows 2077 rArchive.Write(aMagicMarker); 2078 2079 mpDirectoryRecord->Serialize(rArchive); 2080 } 2081 2082 // 2083 // 2084 // 2085 if(!mpExcludeFiles) 2086 { 2087 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP; 2088 rArchive.Write(aMagicMarker); 2089 } 2090 else 2091 { 2092 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows 2093 rArchive.Write(aMagicMarker); 2094 2095 mpExcludeFiles->Serialize(rArchive); 2096 } 2097 2098 // 2099 // 2100 // 2101 if(!mpExcludeDirs) 2102 { 2103 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP; 2104 rArchive.Write(aMagicMarker); 2105 } 2106 else 2107 { 2108 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows 2109 rArchive.Write(aMagicMarker); 2110 2111 mpExcludeDirs->Serialize(rArchive); 2112 } 2113 } 2114 2115 // -------------------------------------------------------------------------- 2116 // 2117 // Function 2118 // Name: Location::Deserialize(Archive & rArchive) 2119 // Purpose: Deserializes this object instance from a stream of bytes, using an Archive abstraction. 2120 // 2121 // Created: 2005/04/11 2122 // 2123 // -------------------------------------------------------------------------- 2124 void Location::Deserialize(Archive &rArchive) 2125 { 2126 // 2127 // 2128 // 2129 mpDirectoryRecord.reset(NULL); 2130 if(mpExcludeFiles) 2131 { 2132 delete mpExcludeFiles; 2133 mpExcludeFiles = NULL; 2134 } 2135 if(mpExcludeDirs) 2136 { 2137 delete mpExcludeDirs; 2138 mpExcludeDirs = NULL; 2139 } 2140 2141 // 2142 // 2143 // 2144 rArchive.Read(mName); 2145 rArchive.Read(mPath); 2146 rArchive.Read(mIDMapIndex); 2147 2148 // 2149 // 2150 // 2151 int64_t aMagicMarker = 0; 2152 rArchive.Read(aMagicMarker); 2153 2154 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP) 2155 { 2156 // NOOP 2157 } 2158 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE) 2159 { 2160 BackupClientDirectoryRecord *pSubRecord = new BackupClientDirectoryRecord(0, ""); 2161 if(!pSubRecord) 2162 { 2163 throw std::bad_alloc(); 2164 } 2165 2166 mpDirectoryRecord.reset(pSubRecord); 2167 mpDirectoryRecord->Deserialize(rArchive); 2168 } 2169 else 2170 { 2171 // there is something going on here 2172 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile); 2173 } 2174 2175 // 2176 // 2177 // 2178 rArchive.Read(aMagicMarker); 2179 2180 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP) 2181 { 2182 // NOOP 2183 } 2184 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE) 2185 { 2186 mpExcludeFiles = new ExcludeList; 2187 if(!mpExcludeFiles) 2188 { 2189 throw std::bad_alloc(); 2190 } 2191 2192 mpExcludeFiles->Deserialize(rArchive); 2193 } 2194 else 2195 { 2196 // there is something going on here 2197 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile); 2198 } 2199 2200 // 2201 // 2202 // 2203 rArchive.Read(aMagicMarker); 2204 2205 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP) 2206 { 2207 // NOOP 2208 } 2209 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE) 2210 { 2211 mpExcludeDirs = new ExcludeList; 2212 if(!mpExcludeDirs) 2213 { 2214 throw std::bad_alloc(); 2215 } 2216 2217 mpExcludeDirs->Deserialize(rArchive); 2218 } 2219 else 2220 { 2221 // there is something going on here 2222 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile); 2223 } 2224 } -
box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h
r2977 r2992 22 22 #include "RunStatusProvider.h" 23 23 24 #ifdef ENABLE_VSS 25 # include <comdef.h> 26 # include <Vss.h> 27 # include <VsWriter.h> 28 # include <VsBackup.h> 29 #endif 30 24 31 class Archive; 25 32 class BackupClientContext; 26 33 class BackupDaemon; 34 class ExcludeList; 35 class Location; 27 36 28 37 // -------------------------------------------------------------------------- … … 126 135 const std::string &rLocalPath, 127 136 const std::string &rRemotePath, 137 const Location& rBackupLocation, 128 138 bool ThisDirHasJustBeenCreated = false); 139 140 std::string ConvertVssPathToRealPath(const std::string &rVssPath, 141 const Location& rBackupLocation); 129 142 130 143 private: … … 136 149 bool UpdateItems(SyncParams &rParams, const std::string &rLocalPath, 137 150 const std::string &rRemotePath, 151 const Location& rBackupLocation, 138 152 BackupStoreDirectory *pDirOnStore, 139 153 std::vector<BackupStoreDirectory::Entry *> &rEntriesLeftOver, … … 146 160 box_time_t AttributesHash, bool NoPreviousVersionOnServer); 147 161 void SetErrorWhenReadingFilesystemObject(SyncParams &rParams, 148 const char *Filename);162 const std::string& rFilename); 149 163 void RemoveDirectoryInPlaceOfFile(SyncParams &rParams, 150 164 BackupStoreDirectory* pDirOnStore, … … 169 183 }; 170 184 185 class Location 186 { 187 public: 188 Location(); 189 ~Location(); 190 191 void Deserialize(Archive & rArchive); 192 void Serialize(Archive & rArchive) const; 193 private: 194 Location(const Location &); // copy not allowed 195 Location &operator=(const Location &); 196 public: 197 std::string mName; 198 std::string mPath; 199 std::auto_ptr<BackupClientDirectoryRecord> mpDirectoryRecord; 200 int mIDMapIndex; 201 ExcludeList *mpExcludeFiles; 202 ExcludeList *mpExcludeDirs; 203 204 #ifdef ENABLE_VSS 205 bool mIsSnapshotCreated; 206 VSS_ID mSnapshotVolumeId; 207 std::string mSnapshotPath; 208 #endif 209 }; 210 171 211 #endif // BACKUPCLIENTDIRECTORYRECORD__H 172 212 -
box/trunk/bin/bbackupd/BackupDaemon.cpp
r2986 r2992 1015 1015 (*i)->mpDirectoryRecord->SyncDirectory(params, 1016 1016 BackupProtocolListDirectory::RootDirectory, 1017 locationPath, std::string("/") + (*i)->mName );1017 locationPath, std::string("/") + (*i)->mName, **i); 1018 1018 1019 1019 // Unset exclude lists (just in case) … … 2948 2948 // 2949 2949 // Function 2950 // Name: BackupDaemon::Location::Location()2951 // Purpose: Constructor2952 // Created: 11/11/032953 //2954 // --------------------------------------------------------------------------2955 BackupDaemon::Location::Location()2956 : mIDMapIndex(0),2957 mpExcludeFiles(0),2958 mpExcludeDirs(0)2959 {2960 }2961 2962 // --------------------------------------------------------------------------2963 //2964 // Function2965 // Name: BackupDaemon::Location::~Location()2966 // Purpose: Destructor2967 // Created: 11/11/032968 //2969 // --------------------------------------------------------------------------2970 BackupDaemon::Location::~Location()2971 {2972 // Clean up exclude locations2973 if(mpExcludeDirs != 0)2974 {2975 delete mpExcludeDirs;2976 mpExcludeDirs = 0;2977 }2978 if(mpExcludeFiles != 0)2979 {2980 delete mpExcludeFiles;2981 mpExcludeFiles = 0;2982 }2983 }2984 2985 // --------------------------------------------------------------------------2986 //2987 // Function2988 // Name: BackupDaemon::Location::Deserialize(Archive & rArchive)2989 // Purpose: Deserializes this object instance from a stream of bytes, using an Archive abstraction.2990 //2991 // Created: 2005/04/112992 //2993 // --------------------------------------------------------------------------2994 void BackupDaemon::Location::Deserialize(Archive &rArchive)2995 {2996 //2997 //2998 //2999 mpDirectoryRecord.reset(NULL);3000 if(mpExcludeFiles)3001 {3002 delete mpExcludeFiles;3003 mpExcludeFiles = NULL;3004 }3005 if(mpExcludeDirs)3006 {3007 delete mpExcludeDirs;3008 mpExcludeDirs = NULL;3009 }3010 3011 //3012 //3013 //3014 rArchive.Read(mName);3015 rArchive.Read(mPath);3016 rArchive.Read(mIDMapIndex);3017 3018 //3019 //3020 //3021 int64_t aMagicMarker = 0;3022 rArchive.Read(aMagicMarker);3023 3024 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP)3025 {3026 // NOOP3027 }3028 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE)3029 {3030 BackupClientDirectoryRecord *pSubRecord = new BackupClientDirectoryRecord(0, "");3031 if(!pSubRecord)3032 {3033 throw std::bad_alloc();3034 }3035 3036 mpDirectoryRecord.reset(pSubRecord);3037 mpDirectoryRecord->Deserialize(rArchive);3038 }3039 else3040 {3041 // there is something going on here3042 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);3043 }3044 3045 //3046 //3047 //3048 rArchive.Read(aMagicMarker);3049 3050 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP)3051 {3052 // NOOP3053 }3054 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE)3055 {3056 mpExcludeFiles = new ExcludeList;3057 if(!mpExcludeFiles)3058 {3059 throw std::bad_alloc();3060 }3061 3062 mpExcludeFiles->Deserialize(rArchive);3063 }3064 else3065 {3066 // there is something going on here3067 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);3068 }3069 3070 //3071 //3072 //3073 rArchive.Read(aMagicMarker);3074 3075 if(aMagicMarker == ARCHIVE_MAGIC_VALUE_NOOP)3076 {3077 // NOOP3078 }3079 else if(aMagicMarker == ARCHIVE_MAGIC_VALUE_RECURSE)3080 {3081 mpExcludeDirs = new ExcludeList;3082 if(!mpExcludeDirs)3083 {3084 throw std::bad_alloc();3085 }3086 3087 mpExcludeDirs->Deserialize(rArchive);3088 }3089 else3090 {3091 // there is something going on here3092 THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);3093 }3094 }3095 3096 // --------------------------------------------------------------------------3097 //3098 // Function3099 // Name: BackupDaemon::Location::Serialize(Archive & rArchive)3100 // Purpose: Serializes this object instance into a stream of bytes, using an Archive abstraction.3101 //3102 // Created: 2005/04/113103 //3104 // --------------------------------------------------------------------------3105 void BackupDaemon::Location::Serialize(Archive & rArchive) const3106 {3107 //3108 //3109 //3110 rArchive.Write(mName);3111 rArchive.Write(mPath);3112 rArchive.Write(mIDMapIndex);3113 3114 //3115 //3116 //3117 if(mpDirectoryRecord.get() == NULL)3118 {3119 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP;3120 rArchive.Write(aMagicMarker);3121 }3122 else3123 {3124 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows3125 rArchive.Write(aMagicMarker);3126 3127 mpDirectoryRecord->Serialize(rArchive);3128 }3129 3130 //3131 //3132 //3133 if(!mpExcludeFiles)3134 {3135 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP;3136 rArchive.Write(aMagicMarker);3137 }3138 else3139 {3140 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows3141 rArchive.Write(aMagicMarker);3142 3143 mpExcludeFiles->Serialize(rArchive);3144 }3145 3146 //3147 //3148 //3149 if(!mpExcludeDirs)3150 {3151 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_NOOP;3152 rArchive.Write(aMagicMarker);3153 }3154 else3155 {3156 int64_t aMagicMarker = ARCHIVE_MAGIC_VALUE_RECURSE; // be explicit about whether recursion follows3157 rArchive.Write(aMagicMarker);3158 3159 mpExcludeDirs->Serialize(rArchive);3160 }3161 }3162 3163 // --------------------------------------------------------------------------3164 //3165 // Function3166 2950 // Name: BackupDaemon::CommandSocketInfo::CommandSocketInfo() 3167 2951 // Purpose: Constructor -
box/trunk/bin/bbackupd/BackupDaemon.h
r2983 r2992 158 158 159 159 public: 160 class Location161 {162 public:163 Location();164 ~Location();165 166 void Deserialize(Archive & rArchive);167 void Serialize(Archive & rArchive) const;168 private:169 Location(const Location &); // copy not allowed170 Location &operator=(const Location &);171 public:172 std::string mName;173 std::string mPath;174 std::auto_ptr<BackupClientDirectoryRecord> mpDirectoryRecord;175 int mIDMapIndex;176 ExcludeList *mpExcludeFiles;177 ExcludeList *mpExcludeDirs;178 179 #ifdef ENABLE_VSS180 bool mIsSnapshotCreated;181 VSS_ID mSnapshotVolumeId;182 std::string mSnapshotPath;183 #endif184 };185 186 160 typedef const std::vector<Location *> Locations; 187 161 Locations GetLocations() { return mLocations; } -
box/trunk/lib/win32/emu.cpp
r2962 r2992 1 1 // Box Backup Win32 native port by Nick Knight 2 3 // Need at least 0x0500 to use GetFileSizeEx on Cygwin/MinGW4 #define WINVER 0x05005 2 6 3 #include "emu.h" … … 1081 1078 } 1082 1079 1083 pDir->fd = _wfindfirst((const wchar_t*)pDir->name, &(pDir->info)); 1084 1085 if (pDir->fd == -1) 1080 pDir->fd = FindFirstFileW(pDir->name, &pDir->info); 1081 DWORD tmp = GetLastError(); 1082 1083 if (pDir->fd == INVALID_HANDLE_VALUE) 1086 1084 { 1087 1085 delete [] pDir->name; … … 1112 1110 struct dirent *den = NULL; 1113 1111 1114 if (dp && dp->fd != -1) 1115 { 1116 if (!dp->result.d_name || 1117 _wfindnext(dp->fd, &dp->info) != -1) 1112 if (dp && dp->fd != INVALID_HANDLE_VALUE) 1113 { 1114 // first time around, when dp->result.d_name == NULL, use 1115 // the values returned by FindFirstFile. After that, call 1116 // FindNextFileW to return new ones. 1117 if (!dp->result.d_name || 1118 FindNextFileW(dp->fd, &dp->info) != 0) 1118 1119 { 1119 1120 den = &dp->result; 1120 std::wstring input(dp->info. name);1121 std::wstring input(dp->info.cFileName); 1121 1122 memset(tempbuff, 0, sizeof(tempbuff)); 1122 WideCharToMultiByte(CP_UTF8, 0, dp->info. name,1123 WideCharToMultiByte(CP_UTF8, 0, dp->info.cFileName, 1123 1124 -1, &tempbuff[0], sizeof (tempbuff), 1124 1125 NULL, NULL); 1125 1126 //den->d_name = (char *)dp->info.name; 1126 1127 den->d_name = &tempbuff[0]; 1127 if (dp->info.attrib & FILE_ATTRIBUTE_DIRECTORY) 1128 den->d_type = dp->info.dwFileAttributes; 1129 } 1130 else // FindNextFileW failed 1131 { 1132 // Why did it fail? No more files? 1133 winerrno = GetLastError(); 1134 den = NULL; 1135 1136 if (winerrno == ERROR_NO_MORE_FILES) 1128 1137 { 1129 den->d_type = S_IFDIR;1138 errno = 0; // no more files 1130 1139 } 1131 1140 else 1132 1141 { 1133 den->d_type = S_IFREG;1142 errno = ENOSYS; 1134 1143 } 1135 1144 } … … 1139 1148 errno = EBADF; 1140 1149 } 1150 1141 1151 return den; 1142 1152 } … … 1160 1170 try 1161 1171 { 1162 int finres = -1; 1172 BOOL finres = false; 1173 1163 1174 if (dp) 1164 1175 { 1165 if(dp->fd != -1)1176 if(dp->fd != INVALID_HANDLE_VALUE) 1166 1177 { 1167 finres = _findclose(dp->fd);1178 finres = FindClose(dp->fd); 1168 1179 } 1169 1180 … … 1172 1183 } 1173 1184 1174 if (finres == -1) // errors go to EBADF 1175 { 1185 if (finres == FALSE) // errors go to EBADF 1186 { 1187 winerrno = GetLastError(); 1176 1188 errno = EBADF; 1177 1189 } 1178 1190 1179 return finres;1191 return (finres == TRUE) ? 0 : -1; 1180 1192 } 1181 1193 catch (...) -
box/trunk/lib/win32/emu.h
r2929 r2992 51 51 #endif 52 52 53 // We need WINVER at least 0x0500 to use GetFileSizeEx on Cygwin/MinGW, 54 // and 0x0501 for FindFirstFile(W) for opendir/readdir. 55 // 53 56 // WIN32_WINNT versions 0x0600 (Vista) and higher enable WSAPoll() in 54 57 // winsock2.h, whose struct pollfd conflicts with ours below, so for 55 // now we just set it lower than that, to Windows 2000. 58 // now we just set it lower than that, to Windows XP (0x0501). 59 56 60 #ifdef WINVER 57 #if WINVER != 0x0500 58 #error Must include emu.h before setting WINVER 59 #endif 60 #endif 61 #define WINVER 0x0500 61 # if WINVER != 0x0501 62 // provoke a redefinition warning to track down the offender 63 # define WINVER 0x0501 64 # error Must include emu.h before setting WINVER 65 # endif 66 #endif 67 #define WINVER 0x0501 62 68 63 69 #ifdef _WIN32_WINNT 64 #if _WIN32_WINNT != 0x0500 65 #error Must include emu.h before setting _WIN32_WINNT 66 #endif 67 #endif 68 #define _WIN32_WINNT 0x0500 70 # if _WIN32_WINNT != 0x0501 71 // provoke a redefinition warning to track down the offender 72 # define _WIN32_WINNT 0x0501 73 # error Must include emu.h before setting _WIN32_WINNT 74 # endif 75 #endif 76 #define _WIN32_WINNT 0x0501 69 77 70 78 // Windows headers … … 238 246 { 239 247 char *d_name; 240 unsigned long d_type;248 DWORD d_type; // file attributes 241 249 }; 242 250 243 251 struct DIR 244 252 { 245 intptr_t fd; // filedescriptor 246 // struct _finddata_t info; 247 struct _wfinddata_t info; 248 // struct _finddata_t info; 249 struct dirent result; // d_name (first time null) 250 wchar_t *name; // null-terminated byte string 253 HANDLE fd; // the HANDLE returned by FindFirstFile 254 WIN32_FIND_DATAW info; 255 struct dirent result; // d_name (first time null) 256 wchar_t* name; // null-terminated byte string 251 257 }; 252 258
Note: See TracChangeset
for help on using the changeset viewer.
