tofro wrote:Dilwyn,
see no reason why that wouldn't work.
(snip)
Don't want to discourage you, but my personal opinion is that adding a new method to exchange files is only prone to add even more confusion.
My opinion stands: The header fact needs to be explained to every new QL user anyways.
Zip/Unzip needs to be explained to new users as well.
I am pretty sure adding another mechanism (and piece of software needed) that needs explanation wouldn't help much....
Regards,
Tobias
Agree 100%.
But when every query involving file transfers starts with "I unzipped it to my windows hard disk, copied the file to the ql, then it doesn't work, just says bad parameter" and my reply is "you should have used ql unzip like I said" and the answer is "I didn't know there was a difference" and you've said that for the tenth time that week, the message isn't getting through and I end up feeling I'm wasting my time and energy.
Anyway, while in 100% agreement with you, I did said tinkering and came up with this simply encopier program in BASIC. To see it working, just put a few files in ram1_ (some executables and some not) and run this, tell it to copy from ram1_ to ram2_.
All the files in ram2_ will now be non-executables but with dataspace preserved in the extra 12 bytes. The12 bytes contain identifier "QLIF" , file type long word and dataspace long word. COuld extend this to 64 byte format if dates etc are to be preserved, this is only a proof of concept.
It would obviously need a more refined copier to allow directories etc to be copied. The only "clever" bit about it is that I realised most file handling commands like COPY on emulators do the conversion of modified executables automatically if you copy files from a native (i.e. Windows etc) to a non-native medium like ram, qxl.win or flp.
Anyway, the point about complexity and explaining yet another complication to a newbie is accepted absolutely. Something like this might be useful to Rich because he could say encopy files from a native qemulator directory to another directory, copy the files in windows to another emulator and just run decopy to do the doings on that computer and finally copy them to wherever they're needed. The non-executables like BASIC and text files aren't modified, the executables are, but carry the extra info with them which is easily undone at the other end.
Anyway, it was fun tinkering with it - here's the code for anyone wanting to build on it.
Code: Select all
100 REMark QLIFF - QL Intermediate File Format for copying and transferring files between systems
110 REMark by Dilwyn Jones 2014
120 REMark needs Toolkit 2
130 :
140 REMark ENCOPY a$ TO b$ to make intermediate file
150 REMark DECOPY b$ TO a$ to convert intermediate to normal EXEC
160 REMark only works for type 1 (EXEC) files, not S-ROFF etc
170 :
180 REMark example QLIFF copier
190 CLS : CLS #0
200 INPUT #0,'Copy from ';from$ : IF from$ = '' THEN STOP
210 INPUT #0,'Copy to ';dest$ : IF dest$ = '' THEN STOP
220 DIR\ram1_tmp,from$
230 OPEN_IN #3,ram1_tmp
240 INPUT #3,t$ : INPUT #3,t$ : REMark medium name and capacity
250 :
260 REPeat copying
270 IF EOF(#3) THEN EXIT copying
280 INPUT #3,t$
290 Encopy from$&t$ TO dest$&t$
300 END REPeat copying
310 CLOSE #3
320 DELETE ram1_tmp : REMark hide the evidence
330 PRINT #0,'Copying complete'
340 STOP
350 :
10000 DEFine PROCedure Encopy (from$,dest$)
10010 REMark copy executable file to QLIFF encoded format
10020 LOCal fl,ft,fd,base
10030 PRINT 'Encopying ';from$;' to ';dest$ : REMark remove if not required
10040 ft = FTYP(\from$)
10050 IF ft = 0 THEN
10060 COPY from$ TO dest$ : REMark no need for QLIFF, no executable header
10070 RETurn
10080 END IF
10090 :
10100 REMark assume type 1 for now
10110 fd = FDAT(\from$) : REMark dataspace of job
10120 fl = FLEN(\from$) : REMark length of file
10130 :
10140 REMark allocate space in memory
10150 base = ALCHP(fl+12)
10160 IF base < 0 THEN PRINT #0,'Out of memory.' : RETurn : REMark oops
10170 LBYTES from$,base+12
10180 REMark assembler intermediate identifier header
10190 POKE base,CODE('Q')
10200 POKE base+1,CODE('L')
10210 POKE base+2,CODE('I')
10220 POKE base+3,CODE('F')
10230 POKE_L base+4,ft : REMark file type
10240 POKE_L base+8,fd : REMark dataspace
10250 :
10260 REMark save modified file to destination
10270 SBYTES dest$,base,fl+12
10280 :
10290 REMark deallocate memory used
10300 RECHP base
10310 END DEFine Encopy
10320 :
10330 DEFine PROCedure Decopy (from$,dest$)
10340 REMark copy file and remove QLIFF formatting
10350 LOCal fl,ft,fd,base,ch
10360 PRINT 'Decopying ';from$;' to ';dest$ : REMark remove if not required
10370 ft = FTYP(\from$)
10380 IF ft <> 0 THEN
10390 COPY from$ TO dest$ : REMark no decoding needed
10400 RETurn
10410 END IF
10420 :
10430 REMark type 0 but is it a QLIFF file
10440 qliff = 0 : REMark becomes 1 if a QLIFF file
10450 fl = FLEN(\from$)
10460 IF fl > 12 THEN
10470 ch = FOP_IN(from$)
10480 IF ch >= 0 THEN
10490 IF INKEY$(#ch) = 'Q' THEN
10500 IF INKEY$(#ch) = 'L' THEN
10510 IF INKEY$(#ch) = 'I' THEN
10520 IF INKEY$(#ch) = 'F' THEN qliff = 1 : REMark identified as a QLIFF file
10530 END IF
10540 END IF
10550 END IF
10560 CLOSE #ch
10570 END IF
10580 END IF
10590 :
10600 IF qliff = 0 THEN
10610 REMark not a QLIFF file
10620 COPY from$ TO dest$ : REMark no decoding needed
10630 RETurn
10640 END IF
10650 :
10660 REMark allocate space in memory
10670 base = ALCHP(fl)
10680 IF base < 0 THEN PRINT #0,'Out of memory.' : RETurn : REMark oops
10690 LBYTES from$,base
10700 ft = PEEK_L(base+4) : REMark not strictly needed unless you want to double check
10710 fd = PEEK_L(base+8)
10720 SEXEC dest$,base+12,fl-12,fd
10730 :
10740 REMark release memory used
10750 RECHP base
10760 END DEFine Decopy
10770 :
10780 DEFine PROCedure XTV
10790 OUTLN #0,FLIM_W(#0),FLIM_H(#0),0,0
10800 WINDOW FLIM_W(#0),FLIM_H(#0)-52,0,0 : WINDOW #2,FLIM_W(#0),FLIM_H(#0)-52,0,0 : WINDOW #0,FLIM_W(#0),52,0,FLIM_H(#0)-52
10810 BORDER #1,1,255 : BORDER #2,1,255 : BORDER #0,1,255
10820 CLS : CLS #2 : CLS #0
10830 END DEFine XTV
10840 :
10850 DEFine PROCedure Sa
10860 SAVE win1_basic_qliff_bas
10870 QSAVE win1_basic_qliff
10880 END DEFine Sa