Author Topic: Can someone write a qb64 code for me?  (Read 1885 times)

0 Members and 1 Guest are viewing this topic.

Offline rcamp48

  • Newbie
  • Posts: 62
Can someone write a qb64 code for me?
« on: February 11, 2020, 02:17:52 pm »
Can someone write a QB64 code for me that will take a list of zip files and unzip them (each one has only 1 file, but no file description), its for the Tosek list, I need it to handle subdirectories, shoreten the zip files to 8 chars each (the first 8 chars, but before doing that create a files.diz file and zip the two files into a new zip file for a BBS). My BBS only handles 8 chars per file with the zip extention, but it will read a file decription from the files.diz file before adding the file.

This would be a big help for me to add files to my 3 TBsof disk storage on my BBS called Spy Visits Spy BBS at spyvisitsspybbs.ddns.net, I will of course have a link to this site on the web page and telnet part of the BBS.

Russ Campbell
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline Real2Two

  • Newbie
  • Posts: 18
Re: Can someone write a qb64 code for me?
« Reply #1 on: February 11, 2020, 02:54:54 pm »
I've never found a way to unzip files with qb64. This might be hard to do.

Offline krovit

  • Forum Regular
  • Posts: 179
Re: Can someone write a qb64 code for me?
« Reply #2 on: February 12, 2020, 05:51:41 am »
I've never found a way to unzip files with qb64. This might be hard to do.

Directly from qb64 maybe not, but with SHELL, DOS commands and portable zip software, yes...
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Can someone write a qb64 code for me?
« Reply #3 on: February 12, 2020, 06:16:20 am »
Directly from qb64 maybe not, but with SHELL, DOS commands and portable zip software, yes...

Yep, sounds like he needs a batch file or script instead of a QB64 program.
In order to understand recursion, one must first understand recursion.

Offline Real2Two

  • Newbie
  • Posts: 18
Re: Can someone write a qb64 code for me?
« Reply #4 on: February 12, 2020, 06:51:13 am »
It might be easier to write it in batch but I guess if you use SHELL, you can loop all files (but idk how to do that).

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Can someone write a qb64 code for me?
« Reply #5 on: February 12, 2020, 04:53:43 pm »
Hi. Try this (without warranty) save to BAT file, if your WinZip compressor is in C:\zip

pushd c:\zip
For /f "delims=" %%x in ('DIR /b *.db3 *.gpx') Do 7z a -mx9 "%%~nx.zip" "%%x"

this should compress the db3 and gpx files into files of the same name (and of course with a zip extension)

Offline rcamp48

  • Newbie
  • Posts: 62
Re: Can someone write a qb64 code for me?
« Reply #6 on: February 13, 2020, 09:35:09 am »
The problem is that there is only one file in each zip file, say its an Atari 8 bit file atr file, it will have an extender of .atr, what I want to do is add a files.diz file to a temporary area with the one atr file in it and copy the long file name as a string , create the files.diz file with the correct filename and zip the 2 files back into one zip file. Basically I want to add a files.diz file to a zip file that has no diz files in it automatically, as when I add the fzip files with WcFile.exe from Wildcat 5.0 it will take the long filenames and shorten them to 8 chars.

Russ
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Can someone write a qb64 code for me?
« Reply #7 on: February 13, 2020, 02:06:06 pm »
Use 7ZIP. It uses long file names correctly when decompressing. If you want to unzip with 7Z, enter 7z e [archive name.zip] at the command prompt, or for archive upgrade use 7z u [archive name.zip] [new file].

For long file name (DIZ content) use DIR /x /b > swap.txt, then open this file in QB for input, read record, write it to new diz file and add it as upgrade to zip file.

7Zip download: https://www.7-zip.org/download.html

IF YOU TRY TO ADD to archive unicode file name, use 8.3 format for 7z. Extracted content but then contains correct long name.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Can someone write a qb64 code for me?
« Reply #8 on: February 14, 2020, 03:34:00 pm »
Hi rcamp48,

I wrote the program (perhaps I understood the problem correctly). The program contains 7Zip files and the BAS program (source code and EXE file). Function Description:
Using the direntry.h library, the ZIP files in the current folder are written to memory (I don't have much time, so all the ZIP files are in a common folder with 7Z files), they are extracted one by one into the SWAP subfolder - just ATR files, here again using the direntry.h library, the name of the unpacked file is read and this name is written to the INFO.DIZ file. This file is then added to the ZIP archive using the command and 7Z parameters.

Because I don't own any real ATR files, I did a couple of them (a text file) and tested it with them. It seems to work properly. In the course of the work I thought of a faster procedure, but I did not want to deal with it again. There are ZIP files in the attached archive, see that without INFO.DIZ files, these files will be added to ZIP when the program starts.

I hope it will be useful.

A few problems while working on the program: the SWAP folder must be empty before running the program (the program is it solves, but I write it here in case you remodel it and interrupt the program while the files stay there, then 7Z seemingly sleep), the next thing to look at is that there is no info.diz file in the 7Z and BAS files directory.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Can someone write a qb64 code for me?
« Reply #9 on: February 14, 2020, 05:32:18 pm »
Small upgraded source code, for case, if ZIP archive contains not ATR file:
(just replace ruscam.bas from zip file with this source code)

Code: QB64: [Select]
  1.     FUNCTION load_dir& (s AS STRING)
  2.     FUNCTION has_next_entry& ()
  3.     SUB close_dir ()
  4.     SUB get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
  5.  
  6. REDIM Directories(0) AS STRING, File(0) AS STRING, ZIP(0) AS STRING
  7.  
  8. D$ = _CWD$ 'INSERT PATH HERE
  9.  
  10.  
  11.  
  12. SetPath D$
  13. GetFileList D$, Directories(), File()
  14.  
  15. 'search ZIP archives in current directory
  16. FOR s = 0 TO UBOUND(file)
  17.     separator$ = LCASE$(RIGHT$(File(s), 4))
  18.     IF separator$ = ".zip" THEN
  19.         REDIM _PRESERVE ZIP(i) AS STRING
  20.         ZIP(i) = File(s)
  21.         i = i + 1
  22.     END IF
  23.  
  24.  
  25. PRINT "In directory "; D$; " found this ZIP files:"
  26.     FOR ziplist = 0 TO i - 1
  27.         PRINT ZIP(ziplist)
  28.     NEXT
  29.     PRINT "NONE": END
  30.  
  31. PRINT "Detecting 7Z in directory "; D$
  32. IF _FILEEXISTS("7Z.exe") THEN PRINT " OK" ELSE PRINT " 7Z not found!": END
  33. PRINT "Auto decompressing ZIP archives, finding ATR files and upgrading ZIP files..."
  34. current$ = _CWD$
  35. IF _FILEEXISTS("info.diz") THEN KILL "info.diz"
  36.  
  37. FOR doall = 0 TO i - 1
  38.     PRINT "File: "; doall + 1; "/"; STR$(i)
  39.     c1$ = "7Z x -oswap " + _TRIM$(ZIP(doall)) + " *.atr"
  40.  
  41.     SHELL _HIDE c1$
  42.     CHDIR "swap"
  43.     _DELAY .5
  44.     EraseFileList Directories(), File()
  45.     GetFileList _CWD$, Directories(), File()
  46.  
  47.  
  48.     IF UBOUND(file) < 1 THEN
  49.         PRINT "None ATR file in ZIP archive, ZIP archive is not upgraded."
  50.         _CONTINUE
  51.     END IF
  52.  
  53.     SHELL _HIDE ("del *.atr")
  54.  
  55.     ff = FREEFILE
  56.     OPEN "info.diz" FOR OUTPUT AS #ff
  57.     PRINT #ff, File(1)
  58.  
  59.     PRINT "To ZIP file is add file info.diz, contains text: "; File(1)
  60.     CLOSE ff
  61.  
  62.  
  63.     c2$ = "7Z u " + _TRIM$(ZIP(doall)) + " info.diz"
  64.     NAME "info.diz" AS current$ + "\info.diz"
  65.     _DELAY .3
  66.     CHDIR current$
  67.     SHELL _HIDE c2$
  68.  
  69.     KILL "info.diz"
  70.  
  71.  
  72. SUB SetPath (p$)
  73.     L$ = RIGHT$(p$, 1)
  74.     $IF WIN THEN
  75.         IF L$ <> "\" THEN p$ = p$ + "\"
  76.     $ELSEIF LIN THEN
  77.         if L$ <> "/" then p$ = p$ + "/"
  78.     $END IF
  79.  
  80. SUB EraseFileList (directories() AS STRING, file() AS STRING)
  81.     REDIM directories(0) AS STRING
  82.     REDIM file(0) AS STRING
  83.  
  84. SUB GetFileList (SearchDirectory AS STRING, DirList() AS STRING, FileList() AS STRING)
  85.     CONST IS_DIR = 1
  86.     CONST IS_FILE = 2
  87.     DIM flags AS LONG, file_size AS LONG
  88.  
  89.     REDIM _PRESERVE DirList(100), FileList(100)
  90.     DirCount = 0: FileCount = 0
  91.  
  92.     IF load_dir(SearchDirectory) THEN
  93.         DO
  94.             length = has_next_entry
  95.             IF length > -1 THEN
  96.                 nam$ = SPACE$(length)
  97.                 get_next_entry nam$, flags, file_size
  98.                 IF (flags AND IS_DIR) OR _DIREXISTS(SearchDirectory + nam$) THEN
  99.                     DirCount = DirCount + 1
  100.                     IF DirCount > UBOUND(DirList) THEN REDIM _PRESERVE DirList(UBOUND(DirList) + 100)
  101.                     DirList(DirCount) = nam$
  102.                 ELSEIF (flags AND IS_FILE) OR _FILEEXISTS(SearchDirectory + nam$) THEN
  103.                     FileCount = FileCount + 1
  104.                     IF FileCount > UBOUND(filelist) THEN REDIM _PRESERVE FileList(UBOUND(filelist) + 100)
  105.                     FileList(FileCount) = nam$
  106.                 END IF
  107.             END IF
  108.         LOOP UNTIL length = -1
  109.         close_dir
  110.     ELSE
  111.     END IF
  112.     REDIM _PRESERVE DirList(DirCount)
  113.     REDIM _PRESERVE FileList(FileCount)
  114.  

Offline rcamp48

  • Newbie
  • Posts: 62
Re: Can someone write a qb64 code for me?
« Reply #10 on: March 08, 2020, 05:08:59 pm »
Here is another version of the same program Pete.........  [ You are not allowed to view this attachment ]  
Complete program for anyone that has n Atari Portfolio and a parallel interface on their PC and on their Atari Portfolio, you have to run the install file in the Transfolio 1.01 folder first, to decide whether or not you are using a 64 Bit interface or a 32 Bit interface ..... as far as I know programs compiled in 64 bit will work on 32 Bit ???? I am talking the exe files...

Russ
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer