96 if (attributes.Contains(faReadOnly) == true) {
97 attributes.Remove(faReadOnly);
98 }
99
100 result = ::DeleteFile(lFileName.data()) == TRUE;
101 }
102
103 return result;
104 }
105
106 bool FilePath::DeleteDirectory(const TString DirectoryName) {
107 bool result = false;
108
109 if (DirectoryExists(DirectoryName) == true) {
110 SHFILEOPSTRUCTW fos = {0};
111 TString directoryName = FixPathForPlatform(DirectoryName);
112 DynamicBuffer<TCHAR> lDirectoryName(directoryName.size() + 2);
113 if (lDirectoryName.GetData() == NULL) {
114 return false;
115 }
116 memcpy(lDirectoryName.GetData(), directoryName.data(), (directoryName.size() + 2) * sizeof(TCHAR));
117 lDirectoryName[directoryName.size() + 1] = NULL;
118 // Double null terminate for SHFileOperation.
119
120 // Delete the folder and everything inside.
121 fos.wFunc = FO_DELETE;
122 fos.pFrom = lDirectoryName.GetData();
123 fos.fFlags = FOF_NO_UI;
124 result = SHFileOperation(&fos) == 0;
125 }
126
127 return result;
128 }
129
130 TString FilePath::IncludeTrailingSeparator(const TString value) {
131 TString result = value;
132
133 if (value.size() > 0) {
134 TString::iterator i = result.end();
135 i--;
136
369 result = true;
370
371 if (attributes | FILE_ATTRIBUTE_ARCHIVE) {
372 FAttributes.push_back(faArchive);
373 }
374 if (attributes | FILE_ATTRIBUTE_COMPRESSED) {
375 FAttributes.push_back(faCompressed);
376 }
377 if (attributes | FILE_ATTRIBUTE_DEVICE) {
378 FAttributes.push_back(faDevice);
379 }
380 if (attributes | FILE_ATTRIBUTE_DIRECTORY) {
381 FAttributes.push_back(faDirectory);
382 }
383 if (attributes | FILE_ATTRIBUTE_ENCRYPTED) {
384 FAttributes.push_back(faEncrypted);
385 }
386 if (attributes | FILE_ATTRIBUTE_HIDDEN) {
387 FAttributes.push_back(faHidden);
388 }
389 // if (attributes | FILE_ATTRIBUTE_INTEGRITY_STREAM) {
390 // FAttributes.push_back(faIntegrityStream);
391 // }
392 if (attributes | FILE_ATTRIBUTE_NORMAL) {
393 FAttributes.push_back(faNormal);
394 }
395 if (attributes | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) {
396 FAttributes.push_back(faNotContentIndexed);
397 }
398 // if (attributes | FILE_ATTRIBUTE_NO_SCRUB_DATA) {
399 // FAttributes.push_back(faNoScrubData);
400 // }
401 if (attributes | FILE_ATTRIBUTE_SYSTEM) {
402 FAttributes.push_back(faSystem);
403 }
404 if (attributes | FILE_ATTRIBUTE_OFFLINE) {
405 FAttributes.push_back(faOffline);
406 }
407 if (attributes | FILE_ATTRIBUTE_REPARSE_POINT) {
408 FAttributes.push_back(faSymbolicLink);
409 }
410 if (attributes | FILE_ATTRIBUTE_SPARSE_FILE) {
411 FAttributes.push_back(faSparceFile);
412 }
413 if (attributes | FILE_ATTRIBUTE_READONLY ) {
414 FAttributes.push_back(faReadOnly);
415 }
416 if (attributes | FILE_ATTRIBUTE_TEMPORARY) {
417 FAttributes.push_back(faTemporary);
418 }
419 if (attributes | FILE_ATTRIBUTE_VIRTUAL) {
420 FAttributes.push_back(faVirtual);
|
96 if (attributes.Contains(faReadOnly) == true) {
97 attributes.Remove(faReadOnly);
98 }
99
100 result = ::DeleteFile(lFileName.data()) == TRUE;
101 }
102
103 return result;
104 }
105
106 bool FilePath::DeleteDirectory(const TString DirectoryName) {
107 bool result = false;
108
109 if (DirectoryExists(DirectoryName) == true) {
110 SHFILEOPSTRUCTW fos = {0};
111 TString directoryName = FixPathForPlatform(DirectoryName);
112 DynamicBuffer<TCHAR> lDirectoryName(directoryName.size() + 2);
113 if (lDirectoryName.GetData() == NULL) {
114 return false;
115 }
116 memcpy(lDirectoryName.GetData(), directoryName.data(),
117 (directoryName.size() + 2) * sizeof(TCHAR));
118 lDirectoryName[directoryName.size() + 1] = NULL;
119 // Double null terminate for SHFileOperation.
120
121 // Delete the folder and everything inside.
122 fos.wFunc = FO_DELETE;
123 fos.pFrom = lDirectoryName.GetData();
124 fos.fFlags = FOF_NO_UI;
125 result = SHFileOperation(&fos) == 0;
126 }
127
128 return result;
129 }
130
131 TString FilePath::IncludeTrailingSeparator(const TString value) {
132 TString result = value;
133
134 if (value.size() > 0) {
135 TString::iterator i = result.end();
136 i--;
137
370 result = true;
371
372 if (attributes | FILE_ATTRIBUTE_ARCHIVE) {
373 FAttributes.push_back(faArchive);
374 }
375 if (attributes | FILE_ATTRIBUTE_COMPRESSED) {
376 FAttributes.push_back(faCompressed);
377 }
378 if (attributes | FILE_ATTRIBUTE_DEVICE) {
379 FAttributes.push_back(faDevice);
380 }
381 if (attributes | FILE_ATTRIBUTE_DIRECTORY) {
382 FAttributes.push_back(faDirectory);
383 }
384 if (attributes | FILE_ATTRIBUTE_ENCRYPTED) {
385 FAttributes.push_back(faEncrypted);
386 }
387 if (attributes | FILE_ATTRIBUTE_HIDDEN) {
388 FAttributes.push_back(faHidden);
389 }
390 if (attributes | FILE_ATTRIBUTE_NORMAL) {
391 FAttributes.push_back(faNormal);
392 }
393 if (attributes | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) {
394 FAttributes.push_back(faNotContentIndexed);
395 }
396 if (attributes | FILE_ATTRIBUTE_SYSTEM) {
397 FAttributes.push_back(faSystem);
398 }
399 if (attributes | FILE_ATTRIBUTE_OFFLINE) {
400 FAttributes.push_back(faOffline);
401 }
402 if (attributes | FILE_ATTRIBUTE_REPARSE_POINT) {
403 FAttributes.push_back(faSymbolicLink);
404 }
405 if (attributes | FILE_ATTRIBUTE_SPARSE_FILE) {
406 FAttributes.push_back(faSparceFile);
407 }
408 if (attributes | FILE_ATTRIBUTE_READONLY ) {
409 FAttributes.push_back(faReadOnly);
410 }
411 if (attributes | FILE_ATTRIBUTE_TEMPORARY) {
412 FAttributes.push_back(faTemporary);
413 }
414 if (attributes | FILE_ATTRIBUTE_VIRTUAL) {
415 FAttributes.push_back(faVirtual);
|