Changeset 3654
- Timestamp:
- Oct 6, 2019, 3:50:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/netlabs/macros/tools.e ¶
r3652 r3654 1112 1112 Tool = upcase( leftstr( Tool, 1))''lowcase( substr( Tool, 2)) 1113 1113 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) 1114 1121 -- Check if file exists 1115 if not Exist( .filename) then1122 elseif not Exist( .filename) then 1116 1123 sayerror .filename 'does not exist on disk. Save it first.' 1117 1124 return sayerror( 'File not found') … … 1139 1146 endif 1140 1147 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 1149 1149 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 1150 1156 1151 1157 -- Input file 1152 InFile = EnquoteFileSpec( .filename) 1158 InFile = .filename 1159 EnqInFile = EnquoteFileSpec( InFile) 1153 1160 1154 1161 -- 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) 1156 1165 1157 1166 -- Temporary EA file 1158 EaFile = EnquoteFileSpec( GetTmpPath()''Name'.ea') 1167 EaFile = GetTmpPath()''Basename'.ea' 1168 EnqEaFile = EnquoteFileSpec( EaFile) 1159 1169 1160 1170 -- Log file 1161 LogFile = EnquoteFileSpec( GetTmpPath()'encode.log') 1171 LogFile = GetTmpPath()'encode.log' 1172 EnqLogFile = EnquoteFileSpec( LogFile) 1162 1173 1163 1174 -- Reset readonly file attribute 1164 1175 if GetReadonly() then 1165 quietshell 'attr -r' InFile1176 quietshell 'attr -r' EnqInFile 1166 1177 endif 1167 1178 … … 1170 1181 1171 1182 -- 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) 1187 1187 1188 1188 -- Execute encoding tool … … 1243 1243 endif 1244 1244 -- Load file to view output from tool and prepend Msg 1245 'e /d ' LogFile1245 'e /d 'EnqLogFile 1246 1246 insertline Msg, 1 1247 1247 .modify = 0 … … 1249 1249 endif 1250 1250 1251 if Tool = 'Uconv' then1251 if lowcase( Tool) <> 'recode' then 1252 1252 -- Copy OutFile over InFile 1253 1253 if not Exist( OutFile) then … … 1256 1256 leave 1257 1257 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) 1276 1266 1277 1267 -- Revert
Note:
See TracChangeset
for help on using the changeset viewer.