Skip to content

Commit

Permalink
some windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JacquesLucke committed Nov 12, 2018
1 parent 235127f commit 04eb40a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion pythonFiles/launch_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ def send_dict_as_json(data):
if os.path.exists(symlink_path):
os.remove(symlink_path)

os.symlink(external_addon_directory, symlink_path, target_is_directory=True)
if sys.platform == "win32":
import _winapi
_winapi.CreateJunction(external_addon_directory, symlink_path)
else:
os.symlink(external_addon_directory, symlink_path, target_is_directory=True)

bpy.ops.wm.addon_enable(module=addon_folder_name)

Expand Down
14 changes: 9 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ function COMMAND_newAddon() {
openLabel: 'New Addon'
}).then(value => {
if (value === undefined) return;
tryMakeAddonInFolder(value[0].path, true);
tryMakeAddonInFolder(value[0].fsPath, true);
});
} else if (workspaceFolders.length === 1) {
tryMakeAddonInFolder(workspaceFolders[0].uri.path);
tryMakeAddonInFolder(workspaceFolders[0].uri.fsPath);
} else {
vscode.window.showErrorMessage('Can\'t create a new addon in a workspace with multiple folders yet.');
}
Expand All @@ -80,7 +80,7 @@ function COMMAND_newAddon() {

function COMMAND_launchAddon() {
tryGetBlenderPath(true, blenderPath => {
launch_Single_External(blenderPath, (<vscode.WorkspaceFolder[]>vscode.workspace.workspaceFolders)[0].uri.path);
launch_Single_External(blenderPath, (<vscode.WorkspaceFolder[]>vscode.workspace.workspaceFolders)[0].uri.fsPath);
}, showErrorIfNotCancel);

}
Expand Down Expand Up @@ -206,7 +206,7 @@ function askUser_BlenderPath(onSuccess : (path : string) => void, onError : (rea
onError(CANCEL);
return;
}
let filepath = value[0].path;
let filepath = value[0].fsPath;
testIfPathIsBlender(filepath, is_valid => {
if (is_valid) {
getConfiguration().update('blenderPath', filepath);
Expand Down Expand Up @@ -435,7 +435,11 @@ function runExternalCommand(command : string, args : string[], additionalEnv : a
if (process.platform === 'linux') {
spawn(config.get('linuxExec'), ['-e', command, ...args], {env:env});
} else if (process.platform === 'win32') {
spawn('start', [command, ...args], {env:env});
let fullCommand = 'start "" "' + command.replace('"', '//"') + '" ';
for (let arg of args) {
fullCommand += ' "' + arg.replace('"', '//"') + '" ';
}
exec(fullCommand, {env:env});
}
}

Expand Down

0 comments on commit 04eb40a

Please sign in to comment.