diff --git a/cad_source/components/zebase/uzbpaths.pas b/cad_source/components/zebase/uzbpaths.pas index 1bf7cb1f4..d496223fd 100644 --- a/cad_source/components/zebase/uzbpaths.pas +++ b/cad_source/components/zebase/uzbpaths.pas @@ -74,7 +74,12 @@ function GetSupportPaths:String; //путь к бинарнику function GetBinaryPath:String; //путь к дистрибутиву +function GetDistribPath:String; +procedure SetDistribPath(const APath:String); +//путь к конфигам программы function GetRoCfgsPath:String; +//путь к конфигам юзера +function GetWrCfgsPath:String; //путь к папке временных файлов function GetTempPath:String; //дополнительные пути с файлами поддержки, сюда рути добавляются скриптами при @@ -95,8 +100,11 @@ procedure FromDirsIterator(const APath,AMask,AFirstLoadFileName:String; AProc:TFromDirIterator;AMethod:TFromDirIteratorObj; APData:pointer=nil;AIgnoreDoubles:Boolean=False); -//поиск расположения дистрибутива, см. вариант 2 выше про DataPaths -function FindDistroPath(const CF:TDataFilesExistChecFunc):string; +//поиск расположения конфигов +function FindDistribPath(const CF:TDataFilesExistChecFunc):string; + +//поиск расположения дистрибутива +function FindConfigsPath(const CF:TDataFilesExistChecFunc):string; var //SupportPath сохраняется и настраивается, поэтому в интерфейсе с доступом @@ -106,6 +114,10 @@ function FindDistroPath(const CF:TDataFilesExistChecFunc):string; implementation var + //доступ геттером и сеттером + DistribPath:String; + //DistribPath переопределен + DistribPathOverride:boolean; //остальные переменные с доступом только по геттеру BinaryPath,TempPath,AdditionalSupportPaths,RoCfgsPath,WrCfgsPath:String; @@ -140,10 +152,23 @@ function GetBinaryPath:String; begin result:=BinaryPath; end; +function GetDistribPath:String; +begin + result:=DistribPath; +end; +procedure SetDistribPath(const APath:String); +begin + if not DistribPathOverride then + DistribPath:=APath; +end; function GetRoCfgsPath:String; begin result:=RoCfgsPath; end; +function GetWrCfgsPath:String; +begin + result:=WrCfgsPath; +end; function GetTempPath:String; begin result:=TempPath; @@ -333,7 +358,7 @@ procedure FromDirIterator(const APath,AMask,AFirstLoadFileName:String;AProc:TFro if AIgnoreDoubles then vs.done; end; -function FindDistroPath(const CF:TDataFilesExistChecFunc):string; +function FindConfigsPath(const CF:TDataFilesExistChecFunc):string; var ts:string; begin @@ -351,9 +376,28 @@ function FindDistroPath(const CF:TDataFilesExistChecFunc):string; RoCfgsPath:=Result; end; end; + +function FindDistribPath(const CF:TDataFilesExistChecFunc):string; +var + ts:string; +begin + try + if @cf<>nil then begin + if cf(DistribPath) then + exit(DistribPath); + end; + Result:=''; + finally + if result<>''then + DistribPathOverride:=True; + end; +end; + initialization - BinaryPath:=ExtractFilePath(paramstr(0)); - RoCfgsPath:=ExpandFileName(BinaryPath+'../../cfg'); - WrCfgsPath:=GetAppConfigDir(false); - TempPath:=GetTempDir; + BinaryPath:=ExcludeTrailingPathDelimiter(ExtractFilePath(paramstr(0))); + DistribPath:=ExpandFileName(ConcatPaths([BinaryPath,'..','..','data'])); + DistribPathOverride:=false; + RoCfgsPath:=ExpandFileName(ConcatPaths([BinaryPath,'..','..','cfg'])); + WrCfgsPath:=ExcludeTrailingPathDelimiter(GetAppConfigDir(false)); + TempPath:=ExcludeTrailingPathDelimiter(GetTempDir); end. diff --git a/cad_source/zcad/register/uzcregpaths.pas b/cad_source/zcad/register/uzcregpaths.pas index c18153396..81c27ae96 100644 --- a/cad_source/zcad/register/uzcregpaths.pas +++ b/cad_source/zcad/register/uzcregpaths.pas @@ -28,8 +28,10 @@ initialization units.CreateExtenalSystemVariable(SysVarUnit,SysVarN,GetSupportPaths,expandpath('$(DistribPath)/rtl/system.pas'),InterfaceTranslate,'PATH_Support_Path','String',@SupportPaths); sysvar.PATH.Dictionaries:=@SysParam.saved.DictionariesPath; sysvar.PATH.RoCfg_Path:=@GetRoCfgsPath; + sysvar.PATH.WrCfg_Path:=@GetWrCfgsPath; sysvar.PATH.Support_Paths:=@SupportPaths; - sysvar.PATH.Distrib_Path:=@sysparam.saved.DistribPath; + sysvar.PATH.Distrib_Path:=@GetDistribPath; + sysvar.PATH.PreferedDistrib_Path:=@sysparam.saved.PreferredDistribPath; sysvar.PATH.AdditionalSupport_Paths:=@GetAdditionalSupportPaths; sysvar.PATH.Temp_Path:=@GetTempPath; finalization diff --git a/cad_source/zcad/uzcfilestructure.pas b/cad_source/zcad/uzcfilestructure.pas index ba9bcf956..d9cba2297 100644 --- a/cad_source/zcad/uzcfilestructure.pas +++ b/cad_source/zcad/uzcfilestructure.pas @@ -22,9 +22,7 @@ interface const CFSrtlDir='rtl'; - CFSconfigxmlFile='config.xml'; - CFSsysvarpasFile='sysvar.pas'; - CFSsavedvarpasFile='savedvar.pas'; + CFSsystempasFile='system.pas'; CFScomponentsDir='components'; CFSdefaultlayoutxmlFile='defaultlayout.xml'; @@ -33,6 +31,10 @@ interface CFSlogopngFile='logo.png'; CFSconfigsDir='configs'; + CFSconfigxmlFile='config.xml'; + CFSsysvarpasFile='sysvar.pas'; + CFSsavedvarpasFile='savedvar.pas'; + CFSnavigatorsDir='navigators'; CFSdictionariesDir='dictionaries'; diff --git a/cad_source/zcad/uzcpathmacros.pas b/cad_source/zcad/uzcpathmacros.pas index 8f3a37375..524998234 100644 --- a/cad_source/zcad/uzcpathmacros.pas +++ b/cad_source/zcad/uzcpathmacros.pas @@ -68,7 +68,7 @@ class function TZCADPathsMacroMethods.MacroFuncBinaryPath(const {%H-}Param: stri end; class function TZCADPathsMacroMethods.MacroFuncDistribPath(const {%H-}Param: string; const Data: PtrInt;var {%H-}Abort: boolean): string; begin - result:=sysparam.saved.DistribPath; + result:=GetDistribPath{sysparam.saved.PreferredDistribPath}; end; class function TZCADPathsMacroMethods.MacroFuncDictPath(const {%H-}Param: string; const Data: PtrInt; var {%H-}Abort: boolean): string; diff --git a/cad_source/zcad/uzcsysinfo.pas b/cad_source/zcad/uzcsysinfo.pas index 9d38d2435..8b0858cce 100644 --- a/cad_source/zcad/uzcsysinfo.pas +++ b/cad_source/zcad/uzcsysinfo.pas @@ -141,11 +141,16 @@ procedure ProcessParamStr; finally programlog.leave(IfEntered);end; end; -function DataFilesExistChec(const ACheckedPath:string):boolean; +function ConfigsFilesExistChec(const ACheckedPath:string):boolean; begin result:=DirectoryExists(ConcatPaths([ACheckedPath,CFSconfigsDir])) and FileExists(ConcatPaths([ACheckedPath,CFSconfigsDir,CFSsysvarpasFile])); end; +function DistribFilesExistChec(const ACheckedPath:string):boolean; +begin + result:=DirectoryExists(ConcatPaths([ACheckedPath,CFSrtlDir])) + and FileExists(ConcatPaths([ACheckedPath,CFSrtlDir,CFSsystempasFile])); +end; Procedure GetSysInfo; begin @@ -197,7 +202,8 @@ function DataFilesExistChec(const ACheckedPath:string):boolean; end; procedure FindData; begin - FindDistroPath(DataFilesExistChec); + FindDistribPath(DistribFilesExistChec); + FindConfigsPath(ConfigsFilesExistChec); end; initialization diff --git a/cad_source/zcad/uzcsysparams.pas b/cad_source/zcad/uzcsysparams.pas index 281ce5d4f..ecece3737 100644 --- a/cad_source/zcad/uzcsysparams.pas +++ b/cad_source/zcad/uzcsysparams.pas @@ -43,7 +43,7 @@ tsavedparams=record LangOverride:string;(*'Language override'*) DictionariesPath:string;(*'Dictionaries path'*) LastAutoSaveFile:string;(*'Last autosave file'*) - DistribPath:String;(*'Path to distributive'*) + PreferredDistribPath:String;(*'Path to distributive'*) end; {REGISTERRECORDTYPE tnotsavedparams} tnotsavedparams=record @@ -70,7 +70,7 @@ tsysparam=record LangOverride:''; DictionariesPath:'ru=$(ZCADDictionariesPath)/ru_RU.dic|en=$(ZCADDictionariesPath)/en_US.dic;$(ZCADDictionariesPath)/en_US_interface.dic|abbrv=$(ZCADDictionariesPath)/abbrv.dic'; LastAutoSaveFile:'noAutoSaveFile'; - DistribPath:'sss'); + PreferredDistribPath:'sss'); zcaduniqueinstanceid='zcad unique instance'; var SysParam: tsysparam; @@ -94,7 +94,7 @@ procedure SaveParamToConfig(Config: TConfigStorage; var Params:tsavedparams); Config.SetDeleteValue('LangOverride',Params.LangOverride,DefaultSavedParams.LangOverride); Config.SetDeleteValue('DictionariesPath',Params.DictionariesPath,DefaultSavedParams.DictionariesPath); Config.SetDeleteValue('LastAutoSaveFile',Params.LastAutoSaveFile,DefaultSavedParams.LastAutoSaveFile); - Config.SetDeleteValue('DistribPath',Params.DistribPath,DefaultSavedParams.DistribPath); + Config.SetDeleteValue('PreferredDistribPath',Params.PreferredDistribPath,DefaultSavedParams.PreferredDistribPath); Config.UndoAppendBasePath; end; @@ -145,7 +145,8 @@ procedure LoadParams(xmlfile:string;out Params:tsavedparams); Params.LangOverride:=XMLConfig.GetAnsiValue('LangOverride',DefaultSavedParams.LangOverride); Params.DictionariesPath:=XMLConfig.GetAnsiValue('DictionariesPath',DefaultSavedParams.DictionariesPath); Params.LastAutoSaveFile:=XMLConfig.GetAnsiValue('LastAutoSaveFile',DefaultSavedParams.LastAutoSaveFile); - Params.DistribPath:=XMLConfig.GetAnsiValue('DistribPath',DefaultSavedParams.DistribPath); + Params.PreferredDistribPath:=XMLConfig.GetAnsiValue('PreferredDistribPath',DefaultSavedParams.PreferredDistribPath); + SetDistribPath(Params.PreferredDistribPath); XMLConfig.CloseKey; FreeAndNil(XMLConfig); end; diff --git a/cad_source/zcad/uzcsysvars.pas b/cad_source/zcad/uzcsysvars.pas index eaeb7e792..260a82715 100644 --- a/cad_source/zcad/uzcsysvars.pas +++ b/cad_source/zcad/uzcsysvars.pas @@ -59,20 +59,22 @@ tdebug=record end; {REGISTERRECORDTYPE tpath} tpath=record - Support_Paths:PString;(*'Support files'*) - AdditionalSupport_Paths:TFString;(*'Additional support files'*)(*oi_readonly*) - Preload_Paths:PString;(*'Preload files'*) - Fonts_Paths:PString;(*'Fonts'*) - Alternate_Font:PString;(*'Alternate font file'*) - Template_Path:PString;(*'Templates'*) - Template_File:PString;(*'Default template'*) - LayoutFile:PString;(*'Current layout'*) - Dictionaries:PString;(*'Dictionaries'*) - Distrib_Path:PString;(*'Path to program distributive'*) - RoCfg_Path:TFString;(*'Read only cfg path'*)(*oi_readonly*) - Temp_Path:TFString;(*'Temporary files'*)(*oi_readonly*) - Device_Library:PString;(*'Device base'*) - end; + Distrib_Path:TFString;(*'Path to program distributive'*)(*oi_readonly*) + PreferedDistrib_Path:PString;(*'Prefered path to distributive'*) + RoCfg_Path:TFString;(*'Path to program configs'*)(*oi_readonly*) + WrCfg_Path:TFString;(*'Path to user configs'*)(*oi_readonly*) + Temp_Path:TFString;(*'Temporary files'*)(*oi_readonly*) + Support_Paths:PString;(*'Support files'*) + AdditionalSupport_Paths:TFString;(*'Additional support files'*)(*oi_readonly*) + Preload_Paths:PString;(*'Preload files'*) + Fonts_Paths:PString;(*'Fonts'*) + Alternate_Font:PString;(*'Alternate font file'*) + Template_Path:PString;(*'Templates'*) + Template_File:PString;(*'Default template'*) + LayoutFile:PString;(*'Current layout'*) + Dictionaries:PString;(*'Dictionaries'*) + Device_Library:PString;(*'Device base'*) + end; PTCanvasData=^TCanvasData; {REGISTERRECORDTYPE TCanvasData} TCanvasData=record diff --git a/cad_source/zcad/uzctranslations.pas b/cad_source/zcad/uzctranslations.pas index c8535dcba..e8ea7e2bd 100644 --- a/cad_source/zcad/uzctranslations.pas +++ b/cad_source/zcad/uzctranslations.pas @@ -310,7 +310,7 @@ initialization TranslateLogModuleId:=programlog.RegisterModule('TRANSLATOR'); TranslateSpellerLogModuleId:=ProgramLog.RegisterModule('TRANSLATOR/SPELLER'); DisableTranslateCount:=0; - PODirectory:=ConcatPaths([sysparam.saved.DistribPath,CFSlanguagesDir]); + PODirectory:=ConcatPaths([GetDistribPath,CFSlanguagesDir]); GetLanguageIDs(Lang, FallbackLang); // определено в модуле gettext if sysparam.saved.LangOverride<>'' then begin Lang:=sysparam.saved.LangOverride; diff --git a/environment/runtimefiles/zcadelectrotech/cfg/configs/config.xml b/environment/runtimefiles/zcadelectrotech/cfg/configs/config.xml index 2f6750a03..059c51791 100644 --- a/environment/runtimefiles/zcadelectrotech/cfg/configs/config.xml +++ b/environment/runtimefiles/zcadelectrotech/cfg/configs/config.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file