Skip to content

Instantly share code, notes, and snippets.

@iconifyit
Created September 1, 2020 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iconifyit/b5c7c268915343152b4db3314c0054b3 to your computer and use it in GitHub Desktop.
Save iconifyit/b5c7c268915343152b4db3314c0054b3 to your computer and use it in GitHub Desktop.
Fixes a bug in Adobe CEP where CEP confuses connected drives with local folders when the relative paths are the same. For instance "/Volumes/Users/username" and "/Users/username"
/**
* Bug fix for the issue described at the link below.
* @link https://community.adobe.com/t5/indesign/extendscript-oddity-with-file-folder-on-mac-os-x/m-p/3887816?page=1#M165105
*/
function fixVolumePathBug(filepath) {
if ($.os.toLowerCase().indexOf('mac') === -1) return filepath;
var $HOME = new Folder('~/').fsName;
if (filepath.indexOf($HOME) > 0) {
var parts = filepath.split($HOME);
filepath = $HOME + '/' + parts.pop();
}
return filepath;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment