< prev index next >

src/jdk.jpackage/windows/native/libapplauncher/FilePath.cpp

Print this page




  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 




  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 


< prev index next >