summaryrefslogtreecommitdiff
path: root/editors/picpas/files/patch-Source_Globales.pas
blob: a896b112562a7a93d893b1cbd3a3d01829bee6d5 (plain) (blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
--- Source/Globales.pas.orig	2021-08-01 06:56:07 UTC
+++ Source/Globales.pas
@@ -5,7 +5,7 @@ unit Globales;
 {$mode objfpc}{$H+}
 interface
 uses  Classes, SysUtils, Forms, SynEdit, SynEditKeyCmds, MisUtils,
-      lclType, FileUtil, LazLogger, Menus ;
+      lclType, FileUtil, LazLogger, Menus,Process, LazFileUtils, LazUTF8 ;
 
 const
   NOM_PROG = 'PicPas';   //nombre de programa
@@ -29,6 +29,7 @@ var
    archivoEnt  : string;    //archivo de entrada
    MostrarError: Boolean;   //Bandera para mostrar mensajesde error.
    ActConsSeg  : Boolean;   //Activa consultas en segundo plano
+   S: string;
 
 /////////////// Campos para manejo del diccionario //////////
 var
@@ -176,7 +177,11 @@ End;
 
 initialization
   //inicia directorios de la aplicación
-  patApp      :=  ExtractFilePath(Application.ExeName);  //incluye el '\' final
+  {$ifdef windows}
+  patApp := GetEnvironmentVariableUTF8('appdata')+'\PicPas\';
+  {$else}
+  patApp :=  GetEnvironmentVariableUTF8('HOME')+'/.config/PicPas/';
+  {$endif}
   patSamples  := patApp + 'samples';
   patUnits    := patApp + 'units';
   patTemp     := patApp + 'temp';
@@ -189,41 +194,107 @@ initialization
   archivoEnt  := '';    //archivo de entrada
   //verifica existencia de carpetas de trabajo
   try
+    if not DirectoryExists(patApp) then begin
+        CreateDir(patApp);
+    end;
     if not DirectoryExists(patSamples) then begin
        msgexc(WA_DIR_NOEXIST, [patSamples]);
-       CreateDir(patSamples);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/samples',
+        patSamples
+        ], S);
+      {else}
+        CreateDir(patSamples);
+      {$endif}
     end;
     if not DirectoryExists(patUnits) then begin
        msgexc(WA_DIR_NOEXIST, [patUnits]);
-       CreateDir(patUnits);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/units',
+        patUnits
+        ], S);
+      {else}
+        CreateDir(patUnits);
+      {$endif}
     end;
     if not DirectoryExists(patDevices10) then begin
        msgexc(WA_DIR_NOEXIST, [patDevices10]);
-       CreateDir(patDevices10);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/devices10',
+        patDevices10
+        ], S);
+      {else}
+        CreateDir(patDevices10);
+      {$endif}
     end;
     if not DirectoryExists(patDevices16) then begin
        msgexc(WA_DIR_NOEXIST, [patDevices16]);
-       CreateDir(patDevices16);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/devices16',
+        patDevices16
+        ], S);
+      {else}
+        CreateDir(patDevices16);
+      {$endif}
     end;
     if not DirectoryExists(patDevices17) then begin
        msgexc(WA_DIR_NOEXIST, [patDevices17]);
-       CreateDir(patDevices17);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/devices17',
+        patDevices17
+        ], S);
+      {else}
+        CreateDir(patDevices17);
+      {$endif}
     end;
     if not DirectoryExists(patDevices18) then begin
        msgexc(WA_DIR_NOEXIST, [patDevices18]);
-       CreateDir(patDevices18);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/devices18',
+        patDevices18
+        ], S);
+      {else}
+        CreateDir(patDevices18);
+      {$endif}
     end;
     if not DirectoryExists(patTemp) then begin
        msgexc(WA_DIR_NOEXIST, [patTemp]);
-       CreateDir(patTemp);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/temp',
+        patTemp
+        ], S);
+      {else}
+        CreateDir(patTemp);
+      {$endif}
     end;
     if not DirectoryExists(patSyntax) then begin
        msgexc(WA_DIR_NOEXIST, [patSyntax]);
-       CreateDir(patSyntax);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/syntax',
+        patSyntax
+        ], S);
+      {else}
+        CreateDir(patSyntax);
+      {$endif}
     end;
     if not DirectoryExists(patThemes) then begin
        msgexc(WA_DIR_NOEXIST, [patThemes]);
-      CreateDir(patThemes);
+      {$ifdef freebsd}
+       RunCommand('cp', ['-R',
+        '/usr/local/share/picpas/themes',
+        patThemes
+        ], S);
+      {else}
+        CreateDir(patThemes);
+      {$endif}
     end;
 
   except