Skip to content

Commit

Permalink
Merge pull request wocommunity#997 from timcu/woinstall_delete_empty_…
Browse files Browse the repository at this point in the history
…system

WOInstaller stops with error on Linux and Windows
  • Loading branch information
hugithordarson authored Oct 23, 2022
2 parents c49b1aa + 7c0100e commit bd44b6c
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public File getSystemLibrariesFolder() {
return _systemLibrariesFolder;
}

/**
* This method moves the folders which were designed for macOS
* to the locations required for linux or windows
* If the destination folder is /opt then
* /opt/Library becomes /opt/Local/Library
* /opt/System/Library becomes /opt/Library
* /opt/System is then deleted
* @throws IOException if folders already exist or can't move folders or can't delete empty folder /opt/System
*/
public void renameFolders() throws IOException {
File localFolder = new File(_destinationFolder, "Local");
if (localFolder.exists()) {
Expand All @@ -57,11 +66,12 @@ public void renameFolders() throws IOException {
if (!_systemLibrariesFolder.renameTo(libraryFolder)) {
throw new IOException("Failed to move '" + _systemLibrariesFolder + "' to '" + libraryFolder + "'.");
}
_systemLibrariesFolder = libraryFolder;

// Delete empty folder /opt/System BEFORE reassigning _systemLibrariesFolder otherwise we will lose reference to it
if (!_systemLibrariesFolder.getParentFile().delete()) {
throw new IOException("Failed to delete '" + _systemLibrariesFolder.getParentFile() + ".");
}
_systemLibrariesFolder = libraryFolder;

System.out.println("Done");
}
}

0 comments on commit bd44b6c

Please sign in to comment.