/* Initialize the temporary directory */ /* Temporary directory Initialization Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /*:VRX */ _InitTempDir: IF options.!debug == 1 THEN say time()' _InitTempDir() started' /* Get temporary directory */ HaveNoTMPDIR = 0 TempDir = translate(value('TMPDIR',,'OS2ENVIRONMENT'),'\','/') IF options.!debug == 1 THEN say ' TMPDIR = "'TempDir'"' if TempDir = '' then do HaveNoTMPDIR = 1 TempDir = translate(value('TEMP',,'OS2ENVIRONMENT'),'\','/') IF options.!debug == 1 THEN say ' TEMP = "'TempDir'"' end if TempDir = '' then do TempDir = translate(value('TMP',,'OS2ENVIRONMENT'),'\','/') IF options.!debug == 1 THEN say ' TMP = "'TempDir'"' end if TempDir = '' then do TempDir = directory() IF options.!debug == 1 THEN say ' Use current dir="'TempDir'"' end if HaveNoTMPDIR then do say 'WARNING! Setting missing TMPDIR variable to "'TempDir'".' IF options.!debug == 1 THEN say ' WARNING! Setting missing TMPDIR variable to "'TempDir'".' ok = value('TMPDIR',TempDir,'OS2ENVIRONMENT') end /* Remove trailing \, translate tabs into blanks */ TempDir = translate(strip(TempDir,'T','\'),' ','09'x) /* Check if there are trailing blanks now - this is an error! */ if strip(TempDir) <> TempDir then do say 'WARNING! Remove trailing blanks and tabs from temporary directory!' ok = value('TMPDIR',strip(TempDir),'OS2ENVIRONMENT') end /* In case it does not exist, create it */ if \VRFileExists(TempDir) then do say 'WARNING! Temporary directory had to be created!' ok = SysMkDir(TempDir) end /* make sure there is a trailing "\" */ Tempdir = strip(TempDir)||'\' IF options.!debug == 1 THEN say time()' _InitTempDir() done, we will use "'TempDir'"' return _ChkTempFreeSpace: IF options.!debug == 1 THEN say time()' _ChkTempFreeSpace() started' /* Check free space */ TempDrvInfo = SysDriveInfo(left(TempDir,2)) parse var TempDrvInfo . TempFreeSpace . . if TempFreeSpace < 1048576 then do say 'Warning: Free space on "'||TempDir||'" low!' end drop TempDrvInfo IF options.!debug == 1 THEN say time()' _ChkTempFreeSpace() done, got "'TempFreeSpace'"' return TempFreeSpace