forked from petrowsky/fmpfunctions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
file.ospath.fmfn
27 lines (24 loc) · 1007 Bytes
/
file.ospath.fmfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
*=====================================================
*file.ospath( path; escaped )
*
*RETURNS: (string) an os cleaned version of a path.
*PARAMS path = (string) name of the file/folder location
* escaped = (bool) whether the path should escape special characters
*DEPS: none
*NOTES: ScriptMaster and some other plugins do their own escaping internally
*This function will also work on a return delimited list of paths
*=====================================================
*
*/
Let( [
_Windows = Abs( Get( SystemPlatform ) ) - 1;
_NewPath = If ( Left( path; 5) = "file:"; Substitute( Middle( path; 6; 1000000 ); "¶file:"; "¶" ); path );
_MacPath = "/Volumes" & Substitute( _NewPath; ¶; "¶/Volumes");
_WinPath = Substitute( Middle( Substitute ( _NewPath ; "/" ; "\\" ); 2; 1000000 ); "¶\\"; "¶")
];
If ( _Windows;
If ( escaped; _WinPath; _WinPath );
If ( escaped; Substitute( _MacPath; [" "; "\ "]; [","; "\,"] ); _MacPath )
)
)