Changeset 3654


Ignore:
Timestamp:
Oct 6, 2019, 3:50:02 PM (5 years ago)
Author:
Andreas Schnellbacher
Message:
  • Added preserve of fileinfo and EA to Encode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/netlabs/macros/tools.e

    r3652 r3654  
    11121112      Tool = upcase( leftstr( Tool, 1))''lowcase( substr( Tool, 2))
    11131113
     1114      -- Handle virtual file
     1115      lp = lastpos( '\', .filename)
     1116      if lp = 0 then
     1117         -- A virtual file: save it as tmp file
     1118         File = GetTmpPath()''.filename
     1119         'Save 'File
     1120         lp = lastpos( '\', .filename)
    11141121      -- Check if file exists
    1115       if not Exist( .filename) then
     1122      elseif not Exist( .filename) then
    11161123         sayerror .filename 'does not exist on disk. Save it first.'
    11171124         return sayerror( 'File not found')
     
    11391146      endif
    11401147
    1141       -- Handle virtual file and get Name
    1142       lp = lastpos( '\', .filename)
    1143       if lp = 0 then
    1144          -- A virtual file: save it as tmp file
    1145          File = GetTmpPath()''.filename
    1146          'Save 'File
    1147          lp = lastpos( '\', .filename)
    1148       endif
     1148      -- Get Name and Basename
    11491149      Name = substr( .filename, lp + 1)
     1150      lp2 = lastpos( '.', Name)
     1151      if lp2 > 1 then
     1152         Basename = leftstr( Name, lp2 - 1)
     1153      else
     1154         Basename = Name
     1155      endif
    11501156
    11511157      -- Input file
    1152       InFile = EnquoteFileSpec( .filename)
     1158      InFile = .filename
     1159      EnqInFile = EnquoteFileSpec( InFile)
    11531160
    11541161      -- Temporary output file
    1155       OutFile = EnquoteFileSpec( GetTmpPath()''Name'.'lowcase( Tool))
     1162      --OutFile = GetTmpPath()''Name'.'lowcase( Tool)
     1163      OutFile = GetTmpPath()''Basename'.enc'
     1164      EnqOutFile = EnquoteFileSpec( OutFile)
    11561165
    11571166      -- Temporary EA file
    1158       EaFile = EnquoteFileSpec( GetTmpPath()''Name'.ea')
     1167      EaFile = GetTmpPath()''Basename'.ea'
     1168      EnqEaFile = EnquoteFileSpec( EaFile)
    11591169
    11601170      -- Log file
    1161       LogFile = EnquoteFileSpec( GetTmpPath()'encode.log')
     1171      LogFile = GetTmpPath()'encode.log'
     1172      EnqLogFile = EnquoteFileSpec( LogFile)
    11621173
    11631174      -- Reset readonly file attribute
    11641175      if GetReadonly() then
    1165          quietshell 'attr -r' InFile
     1176         quietshell 'attr -r' EnqInFile
    11661177      endif
    11671178
     
    11701181
    11711182      -- Unlock caused by others
    1172       quietshell 'unlock' InFile
    1173 
    1174       -- Split Eas to an .ea file
    1175       Cmd = 'eautil' InFile EaFile '/s /r'
    1176       quietshell Cmd
    1177       if rc <> 0 then
    1178          sayerror 'Error from eautil: rc = 'rc', Cmd = 'Cmd
    1179          leave
    1180       endif
    1181 
    1182       -- Create a 0 byte file if no EAs were found.
    1183       -- This allows for replacing EAs later on join.
    1184       if not Exist( EaFile) then
    1185          call CopyFile( 'nul', EaFile)
    1186       endif
     1183      quietshell 'unlock' EnqInFile
     1184
     1185      -- Save FileInfo and create EaFile
     1186      call SaveFileInfoEa( InFile, FileInfo, EaFile)
    11871187
    11881188      -- Execute encoding tool
     
    12431243         endif
    12441244         -- Load file to view output from tool and prepend Msg
    1245          'e /d 'LogFile
     1245         'e /d 'EnqLogFile
    12461246         insertline Msg, 1
    12471247         .modify = 0
     
    12491249      endif
    12501250
    1251       if Tool = 'Uconv' then
     1251      if lowcase( Tool) <> 'recode' then
    12521252         -- Copy OutFile over InFile
    12531253         if not Exist( OutFile) then
     
    12561256            leave
    12571257         endif
    1258 
    1259          Cmd = 'copy' OutFile InFile
    1260          quietshell Cmd
    1261          if rc <> 0 then
    1262             sayerror 'Error from copy: rc = 'rc', Cmd = 'Cmd
    1263             leave
    1264          endif
    1265 
    1266          quietshell 'del' OutFile
    1267       endif
    1268 
    1269       -- Join Eas from an .ea file. EaFile must exist.
    1270       Cmd = 'eautil' InFile EaFile '/j /o'
    1271       quietshell Cmd
    1272       if rc <> 0 then
    1273          sayerror 'Error from eautil: rc = 'rc', Cmd = 'Cmd
    1274          leave
    1275       endif
     1258         call CopyFile( OutFile, Infile)
     1259         if not rc then
     1260            call DeleteFile( OutFile)
     1261         endif
     1262      endif
     1263
     1264      -- Restore FileInfo and join EaFile
     1265      call RestoreFileInfoEa( InFile, FileInfo, EaFile)
    12761266
    12771267      -- Revert
Note: See TracChangeset for help on using the changeset viewer.