Longfile Names for OSREAD and OSWRITE (AREV Specific)
At 20 APR 2004 04:36:03PM Ralph Johler wrote:
Our Arev 3.12 Novell 5 application needs to support longfile names for text files. They have names similar to this:
"20040420154022.ABCD1234.00002.usr.1234567890"
I found this Eric the Emu post, which almost works!
but it doesn't support the multiple "dots" in the blasted long name.
Does anyone know of a method to allow Arev to OSWRITE/OSREAD these files?
At 20 APR 2004 04:53PM Richard Wilson wrote:
I been using cscript for quite awhile out of revg by creating a temporary 8.3 dos format temp file. replace HOLD.NAME & ORIG.HOLD.NAME with whatever you wish
standard osbwrite stuff then
PCPERFORM 'CSCRIPT ':bw_renam.vbs:' "':HOLD.NAME:'" "':ORIG.HOLD.NAME:'" nologo' where bw_renam.vbs is Dim fso Set fso=CreateObject("Scripting.FileSystemObject") FromFile=Wsh.Arguments(0) ToFile=Wsh.Arguments(1) Exists=fso.FileExists(ToFile) if Exists then fso.DeleteFile ToFile end if fso.MoveFile FromFile, ToFile note: this is for the write, something similar would probably work for read side of things Rich </QUOTE> —- === At 20 APR 2004 08:13PM Steve Smith wrote: === <QUOTE>What is the exact syntax of your function call, ie the long path\filename? </QUOTE> —- === At 21 APR 2004 09:43AM Ralph Johler wrote: === <QUOTE>Steve Eric's function syntax is this this: DECLARE FUNCTION MAKELFN SHORTNAME=MAKELFN("C:\Thisisaverylongfilename") OSOPEN SHORTNAME TO HANDLE THEN * whatever you need to do goes here END We can control the path name, so our path is all under the dos limits for path names. The file name is like this: "20040420154022.ABCD1234.00002.usr.1234567890" When I run Eric's function with our fat filename and multiple 'dots' his function crashes. Here is the crash version: DECLARE FUNCTION MAKELFN SHORTNAME=MAKELFN("C:\20040420154022.ABCD1234.00002.usr.1234567890") OSOPEN SHORTNAME TO HANDLE THEN * whatever you need to do goes here END When I run it this way, this is the it works version: DECLARE FUNCTION MAKELFN SHORTNAME=MAKELFN("C:\20040420154022ABCD123400002usr.1234567890") OSOPEN SHORTNAME TO HANDLE THEN * whatever you need to do goes here END Note that the only difference in the filename is the absence of the multiple dots. FYI Here is Eric the Emu source (it's all geek to me): * $MAKELFN is a utility to to create files with long file names. The function returns the short file name alias which AREV can then use. If the long filename already exists then the function simply returns the short filename to use, without creating anything. - Eric To create the object, run the following code: A=\02000000000000000000E92F02FF4D41\ A:=\4B454C464EFF436F7079726967687420\ A:=\28632920313939392062792045726963\ A:=\20456D752EFF00000000000000000000\ FOR I=1 TO 31 A:=\00000000000000000000000000000000\ NEXT I A:=\0000000000000000000000002EC7063E\ A:=\0200000E1F0E07BB3C01BE3A00B90001\ A:=\C60700C604004346E2F6B40DBA01002E\ A:=\FF1E0A00BF3A00F3A40E1FB86C71BB02\ A:=\00B90000BA1100BE3A00BF0100CD2172\ A:=\512EA33A01B43E2E8B1E3A01B86071B1\ A:=\01B580BE3A00BF3C01CD217235BB3C01\ A:=\8A1780FA007408432EFF063E02EBF1BE\ A:=\3C012E8B0E3E02B40F2EFF1E0A0057F3\ A:=\A45F2E8B0E3E0233C033D2B4102EFF1E\ A:=\0A00CB\ OPEN 'BP' TO BP.FILE THEN WRITE A TO BP.FILE, "$MAKELFN" END * Remember to catalog $makelfn *** </QUOTE> —- === At 21 APR 2004 09:46AM Ralph Johler wrote: === <QUOTE>Richard This will work if we activate windows scripts, something I may not be able to get going due to our security policies. Thanks I test this out! </QUOTE> —- === At 26 APR 2004 04:25PM Larry Deibel wrote: === <QUOTE>Your routine to create long file names works. The file names are created however, on my Win98se machine the file is not accessable. I can't open it in Arev nor get access to it with Notepad. From Notepad I get "Access denied by the operating system". No DOS attributes set. Dir and Del work so the name is there. Do not plan to test on 95 as the job will be run on one of three 98 machines. </QUOTE> —- === At 07 MAY 2004 12:34PM Ralph Johler wrote: === <QUOTE>FYI - Here is what worked for us, for any of you in the future with this problem. 1. We create and oswrite to the csv file, using an 8.3 dos filename. 2. Just before we ftp this file, we call an r/basic sub with 3 args - from_filename - to_filename - path the sub oswrites a ms-batch file RENAME.BAT as follows: "REN ":path:from_filename:" ":to_file:" ":CHAR(10):"EXIT" the sub then does this PERFORM 'SUSPEND EXIT CMD /C START RENAME.BAT' which renames the file with the long filename. 3. When an incoming filename is too long, we use Arev with DIRLIST() to obtain the long filename (which we can detect by the tilde '~'). We then call the above sub, but with from_filename as the 'tilded' version and to_filename as our new short 8.3 filename. Once renamed we use that short name within our Arev programs. Since the users can only see the first 6 char of the long filename and these first 6 are always the same, we like a unique name to the dos file - out batch id. So instead of 200405~1.TXT then see ID123456.TXT The "Emu" code worked for us, but not with the require multi-dot long filenames, as in MAMA.NEEDS.A.NEW.PAIR.OF.SHOES The vbs script also worked, but we decided to NOT install Windows scripting on our servers. Something about security risks…. </QUOTE> —- === At 07 MAY 2004 12:43PM Ralph Johler wrote: === <QUOTE>FYI - Here is what worked for us, for any of you in the future with this problem. 1. We create and oswrite to the csv file, using an 8.3 dos filename. 2. Just before we ftp this file, we call an r/basic sub with 3 args - from_filename - to_filename - path the sub oswrites a ms-batch file RENAME.BAT as follows: "REN ":path:from_filename:" ":to_file:" ":CHAR(10):"EXIT" the sub then does this PERFORM 'SUSPEND EXIT CMD /C START RENAME.BAT' which renames the file with the long filename. 3. When an incoming filename is too long, we use Arev with DIRLIST() to obtain the long filename (which we can detect by the tilde '~'). We then call the above sub, but with from_filename as the 'tilded' version and to_filename as our new short 8.3 filename. Once renamed we use that short name within our Arev programs. Since the users can only see the first 6 char of the long filename and these first 6 are always the same, we like a unique name to the dos file - out batch id. So instead of 200405~1.TXT then see ID123456.TXT The "Emu" code worked for us, but not with the require multi-dot long filenames, as in MAMA.NEEDS.A.NEW.PAIR.OF.SHOES The vbs script also worked, but we decided to NOT install Windows scripting on our servers. Something about security risks…. </QUOTE> —- === At 10 MAY 2004 12:05PM warren a wrote: === <QUOTE>Why not write a generic rename.bat? REN %1 %2 EXIT and use PERFORM 'SUSPEND EXIT CMD /C START RENAME.BAT ':path:from_filename:' ':to_file No OSWRITE, and no worries of multiuser contention of writing to RENAME.BAT. </QUOTE> —- === At 13 MAY 2004 02:28PM Ralph Johler wrote: === <QUOTE>]] Cause then I have to ensure that rename.bat exists and doesn't get deleted/changed. ]]] OSWRITE creates the bat file if it has been deleted/renamed/changed, AND if there is a problem we have the 'audit trial' of the last bat file created/executed. We have a 'process lock' invoked when this longfilename creating is done - there can be only one! BUT your way is less steps, less complex. Simple is better! Thanks </QUOTE> —- === At 17 MAY 2004 11:31AM warren a wrote: === <QUOTE>]]Cause then I have to ensure that rename.bat exists and doesn't get deleted/changed. Put it in a common directory on the network, flagged as read/execute only for all user except admins ]]OSWRITE creates the bat file if it has been deleted/renamed/changed, AND if there is a problem we have the 'audit trial' of the last bat file created/executed. We have a 'process lock' invoked when this longfilename creating is done - there can be only one! Keep an audit trail in ARev: Timestamp, user, station id, from-to filenames. </QUOTE> —- === At 16 OCT 2004 11:42AM Hippo wrote: === <QUOTE>A bit late … I did some tests with makelfn: It worked well for me even with multiple dots. If returned shortname is empty, the shortname corresponding to longname by the OS is somehow invalid. (an example is "1234567890-1234.ABCD1234.12345.usr.1234567890" … "-" inserted to working example). Oops, now, when I am trying to repeat the experiments, MAKELFN returns "" even on 8.3 names. I have restarted AREV and tested that $MAKELFN was not changed. Even after computer restart MAKELFN does not work on "123456.12" filename. What happens? P.S.: The code mklfn is not robust as you can invoke its code rewriting (with dangerous results) by passing longer argument than it expects. But this was not the case (it works fine for longfilename of length at least 256). P.P.S.: I haven't invoke MAKELFN with name longer than 45 bytes. </QUOTE> —- === At 20 OCT 2004 02:47PM Hippo wrote: === <QUOTE>The problem was … I am not sure … cld? handles? Here is my MAKELFN based on the same idea: Use it on your own risk ;) A=' A:=\02010000000000000000E98601\:'MAKELFN(LongName) by Hippo. A' A:=t least first 104h bytes of LongName are significant. If e' A:=verything OK, returns ShortName and Parameter is unchanged' A:=. If some INT 21h call fails, returned value says which on' A:=e failed. Parameter corresponds to AX returned in that cas' A:=e. 1 - open LongName handle 2 - Truncate filename 3 - Clos' A:=e handle. Works even when no more handles error is returne' A:=d. Enjoy It;)':\B40DBA01002EFF1E0A008CCB8EC30BC9743DB80401\ A:=\3BC173028BC8BF9200FCF3A426880D8EDBB86C71BB0200BA1100BE9200\ A:=\BF0100CD21730B3D04007414B90100EB4F908BD8B43ECD217306B90300\ A:=\EB4190B86071B90180BE9200BF1100CD21722D33C0B9FFFFBF11008BD7\ A:=\FCF2AEF7D9498BF251B40FFF1E0A00595751FCF3A4595F33D2B80010FF\ A:=\1E0A00EB1990B9020033D250B80012FF1E0A0059B80012BA0100FF1E0A\ A:=\00CB\ OPEN 'OBJECT' TO BP.FILE THEN WRITE A TO BP.FILE, '$MAKELFN' END PERFORM "SETPROGRAM OBJECT MAKELFN" ———— Some tests: DECLARE SUBROUTINE MSG DECLARE FUNCTION MAKELFN A=This text is only for testing purposes!":char(13):char(10) *B=Very strange and rather long file name. Isn't it." ; * OK *B=Very-strange.and*rather long/file name. Isn't it." ;* OPEN 123 *B=Very-strange.and rather long/file name. Isn't it." ; * OPEN 3 *B=Very-strange.and rather long file name. Isn't it." ; * OK B=Very-strange.and rather long file name. Isn't it. It works!" ; * OK GOSUB TEST B_=B FOR J=1 TO 500 B=B_:J GOSUB TEST NEXT J STOP TEST: C=MAKELFN(B) BEGIN CASE CASE LEN(C) ] 1; * OK CASE C=1; MSG("Open Error:":B);RETURN CASE C=2; MSG("Trunc Error:":B);RETURN CASE C=3; MSG("Close Error:":B);RETURN *CASE 1; * OK END CASE OSOPEN C TO HANDLE ELSE MSG("File ":C:" cannot be opened") RETURN END OFFSET=0 FOR I=1 TO 2000 OSBWRITE A TO HANDLE AT OFFSET OFFSET+=LEN(A) NEXT I OSCLOSE HANDLE RETURN </QUOTE> View this thread on the forum...