-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathfile.setpath.fmfn
67 lines (57 loc) · 2.38 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* =====================================================
* 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 are returned via an evaluate using the inbound 'location' var as a reference to the named Let() var
_Paths = "Let( [
isWindows = Abs( Get( SystemPlatform ) ) - 1;
isXP = isWindows and Get ( SystemVersion ) < 6;
_Desktop = Get( DesktopPath );
_Documents = Get( DocumentsPath );
_Application = Get( FileMakerPath );
_File = Substitute( Get( FilePath ) ; \"file:\" ; \"\" );
_Preferences = Get( PreferencesPath );
_Temp = If ( isWindows ; Substitute ( _Documents ; \"My Documents\" ; \"Local Settings\" ) & \"Temp/\"; \"/private/tmp/\" );
_Extensions = Get( FileMakerPath ) & \"Extensions/\";
path.win = If ( isXP ; \"/Local Settings/Application Data/FileMaker/Extensions/\" ; \"/AppData/Local/FileMaker/Extensions/\" );
path.mac = \"/Library/Application Support/FileMaker/Extensions/\";
_SharedExt = Substitute ( _Desktop ; \"/Desktop/\"; If ( isWindows ; path.win ; path.mac ) );
_FMTemp = Get ( TemporaryPath )
];¶_" &
location
& ")";
// Only these values for folder are possible
_Match = "Desktop Documents Application File Preferences Temp Extensions SharedExt FMTemp";
// 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
)
/*
//Unit test
List (
file.setpath ( "Desktop" ; "" );
file.setpath ( "Documents" ; "" );
file.setpath ( "Application" ; "" );
file.setpath ( "File" ; "" );
file.setpath ( "Preferences" ; "" );
file.setpath ( "Temp" ; "" );
file.setpath ( "Extensions" ; "" );
file.setpath ( "SharedExt" ; "" );
file.setpath ( "FMTemp" ; "" );
)
*/