| 1 | /* Initialize the temporary directory */ | 
|---|
| 2 |  | 
|---|
| 3 | /*:VRX */ | 
|---|
| 4 | _InitTempDir: | 
|---|
| 5 | IF options.!debug == 1 THEN say time()' _InitTempDir() started' | 
|---|
| 6 | /* Get temporary directory */ | 
|---|
| 7 | HaveNoTMPDIR  = 0 | 
|---|
| 8 | TempDir       = translate(value('TMPDIR',,'OS2ENVIRONMENT'),'\','/') | 
|---|
| 9 | IF options.!debug == 1 THEN say '  TMPDIR="'TempDir'"' | 
|---|
| 10 | if TempDir = '' then do | 
|---|
| 11 | HaveNoTMPDIR  = 1 | 
|---|
| 12 | TempDir = translate(value('TEMP',,'OS2ENVIRONMENT'),'\','/') | 
|---|
| 13 | IF options.!debug == 1 THEN say '  TEMP="'TempDir'"' | 
|---|
| 14 | end | 
|---|
| 15 | if TempDir = '' then do | 
|---|
| 16 | TempDir = translate(value('TMP',,'OS2ENVIRONMENT'),'\','/') | 
|---|
| 17 | IF options.!debug == 1 THEN say '  TMP="'TempDir'"' | 
|---|
| 18 | end | 
|---|
| 19 | if TempDir = '' then do | 
|---|
| 20 | TempDir = directory() | 
|---|
| 21 | IF options.!debug == 1 THEN say '  Use current dir="'TempDir'"' | 
|---|
| 22 | end | 
|---|
| 23 | if HaveNoTMPDIR then do | 
|---|
| 24 | say 'WARNING! Setting missing TMPDIR   variable to "'TempDir'".' | 
|---|
| 25 | IF options.!debug == 1 THEN say '  WARNING! Setting missing TMPDIR   variable to "'TempDir'".' | 
|---|
| 26 | ok = value('TMPDIR',TempDir,'OS2ENVIRONMENT') | 
|---|
| 27 | end | 
|---|
| 28 | /* Remove trailing \, translate tabs into blanks */ | 
|---|
| 29 | TempDir       = translate(strip(TempDir,'T','\'),' ','09'x) | 
|---|
| 30 |  | 
|---|
| 31 | /* Check if there are trailing blanks now - this is an error! */ | 
|---|
| 32 | if strip(TempDir) <> TempDir then do | 
|---|
| 33 | say 'WARNING! Remove trailing blanks and tabs from temporary directory!' | 
|---|
| 34 | ok = value('TMPDIR',strip(TempDir),'OS2ENVIRONMENT') | 
|---|
| 35 | end | 
|---|
| 36 |  | 
|---|
| 37 | /* In case it does not exist, create it */ | 
|---|
| 38 | if  \VRFileExists(TempDir) then do | 
|---|
| 39 | say 'WARNING! Temporary directory had to be created!' | 
|---|
| 40 | ok = SysMkDir(TempDir) | 
|---|
| 41 | end | 
|---|
| 42 |  | 
|---|
| 43 | /* make sure there is a trailing "\" */ | 
|---|
| 44 | Tempdir = strip(TempDir)||'\' | 
|---|
| 45 |  | 
|---|
| 46 | IF options.!debug == 1 THEN say time()' _InitTempDir() done, we will use "'TempDir'"' | 
|---|
| 47 | return | 
|---|
| 48 |  | 
|---|
| 49 | _ChkTempFreeSpace: | 
|---|
| 50 | IF options.!debug == 1 THEN say time()' _ChkTempFreeSpace() started' | 
|---|
| 51 | /* Check free space */ | 
|---|
| 52 | TempDrvInfo   = SysDriveInfo(left(TempDir,2)) | 
|---|
| 53 | parse var TempDrvInfo . TempFreeSpace . . | 
|---|
| 54 | if TempFreeSpace < 1048576 then do | 
|---|
| 55 | say 'Warning: Free space on "'||TempDir||'" low!' | 
|---|
| 56 | end | 
|---|
| 57 | drop TempDrvInfo | 
|---|
| 58 | IF options.!debug == 1 THEN say time()' _ChkTempFreeSpace() done, got "'TempFreeSpace'"' | 
|---|
| 59 | return TempFreeSpace | 
|---|