Procházet zdrojové kódy

ADD: Feature [0001344] Separate UseConfigInProgramDir from all other settings

Alexander Koblov před 7 roky
rodič
revize
91d151a91c

+ 1 - 1
install/create_packages.bat

@@ -62,7 +62,7 @@ rem Move created package
 move release\*.exe %PACK_DIR%
 
 rem Create *.zip package
-patch doublecmd/doublecmd.xml portable.diff
+copy NUL doublecmd\doublecmd.inf
 zip -9 -Dr %PACK_DIR%\doublecmd-%DC_VER%.%CPU_TARGET%-%OS_TARGET%.zip doublecmd 
 
 rem Create help packages

+ 0 - 42
install/darwin/doublecmd.xml

@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<doublecmd DCVersion="0.0.0" ConfigVersion="5">
-  <Configuration Save="True">
-    <UseConfigInProgramDir>False</UseConfigInProgramDir>
-  </Configuration>
-  <Behaviours>
-    <ListFilesInThread>False</ListFilesInThread>
-    <LoadIconsSeparately>True</LoadIconsSeparately>
-  </Behaviours>
-  <Colors>
-    <FileFilters>
-      <Filter>
-        <Name>Pascal sources</Name>
-        <FileMasks>*.pas;*.pp</FileMasks>
-        <Color>32768</Color>
-        <Attributes/>
-      </Filter>
-      <Filter>
-        <Name>Pascal binaries</Name>
-        <FileMasks>*.ppu;*.o;*.dcu</FileMasks>
-        <Color>16711680</Color>
-        <Attributes/>
-      </Filter>
-      <Filter>
-        <Name>Specified Executables</Name>
-        <FileMasks>*</FileMasks>
-        <Color>55758</Color>
-        <Attributes>-rwxrwxr*x</Attributes>
-      </Filter>
-      <Filter>
-        <Name>Executables</Name>
-        <FileMasks>*</FileMasks>
-        <Color>32768</Color>
-        <Attributes>-*x*</Attributes>
-      </Filter>
-    </FileFilters>
-  </Colors>
-  <Icons>
-    <Size>32</Size>
-    <ShowOverlays>True</ShowOverlays>
-  </Icons>
-</doublecmd>

+ 0 - 1
install/darwin/install.sh

@@ -33,7 +33,6 @@ mkdir -p $DC_INSTALL_DIR/plugins/wfx/ftp
 cp -r doublecmd.app/*              $DC_APP_DIR/
 cp -a doublecmd                    $DC_INSTALL_DIR/
 cp -a doublecmd.zdli               $DC_INSTALL_DIR/
-cp -a install/darwin/doublecmd.xml $DC_INSTALL_DIR/
 cp -a doublecmd.ext.example        $DC_INSTALL_DIR/
 cp -a pixmaps.txt                  $DC_INSTALL_DIR/
 cp -a multiarc.ini                 $DC_INSTALL_DIR/

+ 0 - 43
install/linux/doublecmd.xml

@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<doublecmd DCVersion="0.0.0" ConfigVersion="5">
-  <Configuration Save="True">
-    <UseConfigInProgramDir>False</UseConfigInProgramDir>
-  </Configuration>
-  <Colors>
-    <FileFilters>
-      <Filter>
-        <Name>Pascal sources</Name>
-        <FileMasks>*.pas;*.pp</FileMasks>
-        <Color>32768</Color>
-        <Attributes/>
-      </Filter>
-      <Filter>
-        <Name>Pascal binaries</Name>
-        <FileMasks>*.ppu;*.o;*.dcu</FileMasks>
-        <Color>16711680</Color>
-        <Attributes/>
-      </Filter>
-      <Filter>
-        <Name>Specified Executables</Name>
-        <FileMasks>*</FileMasks>
-        <Color>55758</Color>
-        <Attributes>-rwxrwxr*x</Attributes>
-      </Filter>
-      <Filter>
-        <Name>Executables</Name>
-        <FileMasks>*</FileMasks>
-        <Color>32768</Color>
-        <Attributes>-*x*</Attributes>
-      </Filter>
-    </FileFilters>
-  </Colors>
-  <Plugins>
-    <WlxPlugins>
-      <WlxPlugin>
-        <Name>wlxMplayer</Name>
-        <Path>%commander_path%/plugins/wlx/wlxmplayer/wlxmplayer.wlx</Path>
-        <DetectString>(EXT="MPG")|(EXT="AVI")|(EXT="MPEG")|(EXT="FLV")</DetectString>
-      </WlxPlugin>
-    </WlxPlugins>
-  </Plugins>
-</doublecmd>

+ 2 - 1
install/linux/install.sh

@@ -71,7 +71,6 @@ mkdir -p $DC_INSTALL_DIR/plugins/dsx/dsxlocate
 # Copy files
 cp -a doublecmd                    $DC_INSTALL_DIR/
 cp -a doublecmd.zdli               $DC_INSTALL_DIR/
-cp -a install/linux/doublecmd.xml  $DC_INSTALL_DIR/
 cp -a doublecmd.ext.example        $DC_INSTALL_DIR/
 cp -a pixmaps.txt                  $DC_INSTALL_DIR/
 cp -a multiarc.ini                 $DC_INSTALL_DIR/
@@ -138,6 +137,8 @@ if [ -z $CK_PORTABLE ]
     install -d $DC_INSTALL_PREFIX/usr/share/polkit-1/actions
     install -m 644 install/linux/org.doublecmd.root.policy $DC_INSTALL_PREFIX/usr/share/polkit-1/actions/
   else
+    # Mark as portable version
+    touch $DC_INSTALL_DIR/doublecmd.inf
     # Copy documentation
     mkdir -p $DC_INSTALL_DIR/doc
     cp -a doc/*.txt $DC_INSTALL_DIR/doc/

+ 0 - 22
install/windows/doublecmd.xml

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<doublecmd DCVersion="0.0.0" ConfigVersion="5">
-  <Configuration Save="True">
-    <UseConfigInProgramDir>False</UseConfigInProgramDir>
-  </Configuration>
-  <Colors>
-    <FileFilters>
-      <Filter>
-        <Name>Pascal sources</Name>
-        <FileMasks>*.pas;*.pp</FileMasks>
-        <Color>32768</Color>
-        <Attributes/>
-      </Filter>
-      <Filter>
-        <Name>Pascal binaries</Name>
-        <FileMasks>*.ppu;*.o;*.dcu</FileMasks>
-        <Color>16711680</Color>
-        <Attributes/>
-      </Filter>
-    </FileFilters>
-  </Colors>
-</doublecmd>

+ 0 - 1
install/windows/install.bat

@@ -32,7 +32,6 @@ rem Copy files
 copy doc\*.txt                      %DC_INSTALL_DIR%\doc\
 copy doublecmd.exe                  %DC_INSTALL_DIR%\
 copy doublecmd.zdli                 %DC_INSTALL_DIR%\
-copy install\windows\doublecmd.xml  %DC_INSTALL_DIR%\
 copy doublecmd.ext.example          %DC_INSTALL_DIR%\
 copy pixmaps.txt                    %DC_INSTALL_DIR%\
 copy multiarc.ini                   %DC_INSTALL_DIR%\

+ 0 - 4
install/windows/portable.diff

@@ -1,4 +0,0 @@
-4c4
-<     <UseConfigInProgramDir>False</UseConfigInProgramDir>
----
->     <UseConfigInProgramDir>True</UseConfigInProgramDir>

+ 38 - 25
src/uglobs.pas

@@ -1869,34 +1869,41 @@ begin
     Exit(True);
 
   // Check global directory for XML config.
-  if (gpCmdLineCfgDir = EmptyStr) and
-     mbFileExists(gpGlobalCfgDir + 'doublecmd.xml') then
+  if (gpCmdLineCfgDir = EmptyStr) then
   begin
-    gConfig := TXmlConfig.Create(gpGlobalCfgDir + 'doublecmd.xml');
-    gUseConfigInProgramDir := True;
-    if mbFileAccess(gpGlobalCfgDir + 'doublecmd.xml', fmOpenRead or fmShareDenyWrite) then
+    gUseConfigInProgramDir:= mbFileExists(gpGlobalCfgDir + 'doublecmd.inf');
+
+    if gUseConfigInProgramDir or mbFileExists(gpGlobalCfgDir + 'doublecmd.xml') then
     begin
-      LoadConfigCheckErrors(@LoadGlobalConfig, gpGlobalCfgDir + 'doublecmd.xml', ErrorMessage);
-      gUseConfigInProgramDir := gConfig.GetValue(gConfig.RootNode, 'Configuration/UseConfigInProgramDir', False);
-      if not gUseConfigInProgramDir then
+      gConfig := TXmlConfig.Create(gpGlobalCfgDir + 'doublecmd.xml');
+      if mbFileExists(gpGlobalCfgDir + 'doublecmd.xml') then
       begin
-        if mbFileExists(gpCfgDir + 'doublecmd.xml') then
-          // Close global config so that the local config is opened below.
-          FreeAndNil(gConfig)
+        if mbFileAccess(gpGlobalCfgDir + 'doublecmd.xml', fmOpenRead or fmShareDenyWrite) then
+        begin
+          LoadConfigCheckErrors(@LoadGlobalConfig, gpGlobalCfgDir + 'doublecmd.xml', ErrorMessage);
+          gConfig.TryGetValue(gConfig.RootNode, 'Configuration/UseConfigInProgramDir', gUseConfigInProgramDir);
+
+          if not gUseConfigInProgramDir then
+          begin
+            if mbFileExists(gpCfgDir + 'doublecmd.xml') then
+              // Close global config so that the local config is opened below.
+              FreeAndNil(gConfig)
+            else
+              // Local config is used but it doesn't exist. Use global config that has just
+              // been read but set file name accordingly and later save to local config.
+              gConfig.FileName := gpCfgDir + 'doublecmd.xml';
+          end;
+        end
         else
-          // Local config is used but it doesn't exist. Use global config that has just
-          // been read but set file name accordingly and later save to local config.
-          gConfig.FileName := gpCfgDir + 'doublecmd.xml';
+        begin
+          // Configuration file is not readable.
+          AddStrWithSep(ErrorMessage,
+              'Config file "' + gpGlobalCfgDir + 'doublecmd.xml' +
+              '" exists but is not readable.',
+              LineEnding);
+          Exit(False);
+        end;
       end;
-    end
-    else
-    begin
-      // Configuration file is not readable.
-      AddStrWithSep(ErrorMessage,
-          'Config file "' + gpGlobalCfgDir + 'doublecmd.xml' +
-          '" exists but is not readable.',
-          LineEnding);
-      Exit(False);
     end;
   end;
 
@@ -2064,18 +2071,24 @@ begin
      (gpCmdLineCfgDir = EmptyStr) then
     begin
       LoadPaths;
+
       if gUseConfigInProgramDirNew then
       begin
         gpCfgDir := gpGlobalCfgDir;
         UpdateEnvironmentVariable;
+        FileClose(mbFileCreate(gpGlobalCfgDir + 'doublecmd.inf'));
+      end
+      else begin
+        if mbFileExists(gpGlobalCfgDir + 'doublecmd.inf') then
+          mbDeleteFile(gpGlobalCfgDir + 'doublecmd.inf')
       end;
 
-      { Save location of configuration files }
+      { Remove location of configuration files from XML}
       if mbFileAccess(gpGlobalCfgDir + 'doublecmd.xml', fmOpenWrite or fmShareDenyWrite) then
       begin
         TmpConfig := TXmlConfig.Create(gpGlobalCfgDir + 'doublecmd.xml', True);
         try
-          TmpConfig.SetValue(TmpConfig.RootNode, 'Configuration/UseConfigInProgramDir', gUseConfigInProgramDirNew);
+          TmpConfig.DeleteNode(TmpConfig.RootNode, 'Configuration/UseConfigInProgramDir');
           TmpConfig.Save;
         finally
           TmpConfig.Free;