forked from petrowsky/fmpfunctions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile.setpath.fmfn
48 lines (38 loc) · 1.48 KB
/
file.setpath.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* =====================================================
* file.setpath( location; subfolder )
*
* RETURNS: (string) path to file/folder location.
* PARAMS location = (string) name of the folder location
* subfolder = (string) any subfolders you wish to append
* DEPS: none
* NOTES: none
* =====================================================
*
*/
Let(
[
_Windows = Abs( Get( SystemPlatform ) ) - 1;
_Paths = "Let( [
_Windows = Abs( Get( SystemPlatform ) ) - 1;
_Desktop = Get( DesktopPath );
_Documents = Get( DocumentsPath );
_Application = Get( FileMakerPath );
_File = Substitute( Get( FilePath ) ; \"file:\" ; \"\" );
_Preferences = Get( PreferencesPath );
_Temp = If ( _Windows; Substitute ( _Documents ; \"My Documents\" ; \"Local Settings\" ) & \"Temp/\"; \"/private/tmp/\" );
_Extensions = Get( FileMakerPath ) & \"Extensions/\"
];¶_" &
location
& ")";
// Only these values for folder are possible
_Match = "Desktop Documents Application File Preferences Temp Extensions";
// Generate the actual path
_Path = If ( PatternCount( _Match ; location ); Evaluate( _Paths ) ; location ) & If ( not IsEmpty( subfolder ); subfolder );
// Remove the filename
_File = Get( FileName ) & ".fp7";
_HasFile = PatternCount( _Path; _File );
_Path = If ( _HasFile; Substitute( _Path; _File; ""); _Path )
];
_Path
)