1. disks and files
does anybody know how I would be able to take a file that is larger than
a HD floppy (1.44mb) and split that file into parts that will fit onto
more than one floppy?
example : file.exe is 1.83mb The program looks at the file and splits
it into file.01 which is 1.33mb and file.02 which is .50mb and a batch
file file.bat. The batch file contains only the commands
@echo off
cls
echo Splicing the files together
@echo off
copy /b file.01 + file.02 file.exe >nul
cls
How would I do the file size detection and split in Euphoria?
Thanks,
Philip Lettkeman phil.man at juno.com
"Every man has his price. Mine just happens to be the love of my
children."
2. Re: disks and files
At 07:17 AM 10/30/97 EST, you wrote:
>does anybody know how I would be able to take a file that is larger than
>a HD floppy (1.44mb) and split that file into parts that will fit onto
>more than one floppy?
>
>example : file.exe is 1.83mb The program looks at the file and splits
>it into file.01 which is 1.33mb and file.02 which is .50mb and a batch
>file file.bat. The batch file contains only the commands
>
>@echo off
>cls
>echo Splicing the files together
>@echo off
>copy /b file.01 + file.02 file.exe >nul
>cls
>
>How would I do the file size detection and split in Euphoria?
>Thanks,
>Philip Lettkeman phil.man at juno.com
>
>"Every man has his price. Mine just happens to be the love of my
>children."
>
both pkzip and arj will zip multiple files like that. I was assuming you
meant you wanted an external app to zip them, and not euphoria. If not,
sorry for butting in. :)
3. Re: disks and files
On 30 Oct 97 , Philip A Lettkeman wrote:
> does anybody know how I would be able to take a file that is larger
> than a HD floppy (1.44mb) and split that file into parts that will
> fit onto more than one floppy?
You can determine the length of a file using the dir() function.
Knowing the maximun bytes each split should have you can do something
like this:
-----< CODE START >-----
-- SPLIT.EX
-- Daniel Berstein 30/10/97
-- Usage: ex split <filename>
-- Creates a batch file (join.bat) for recreating original file
include file.e
integer source, dest, splits
object size
atom max, offset
sequence filename
max = 1415577 -- About 1.35 MB
-- Read filename
filename = command_line()
if length(filename) < 3 then
puts(1, "Please supply a file to split.\n")
abort(0)
end if
filename = filename[3]
-- Get file size
size = dir(filename)
if atom(size) then
puts(1,"Can't find file " & filename & ".\n")
abort(0)
end if
size = size[1][D_SIZE]
-- Check splits needed
if size/max > 999 then
puts(1, "Too many split files needed!\n")
abort(0)
end if
-- Open source file
source = open(filename, "rb")
if source = -1 then
puts(1, "Can't open file " & filename & "\n.")
abort(0)
end if
splits = 1
offset = 1
-- Main loop
while 1 do
-- Create split file
puts(1, "Creating split file #" & sprintf("%d", splits) & "\n")
dest = open(filename[1..find('.', filename)] & sprintf("%d",splits),"wb")
if dest = -1 then
puts(1, "Can't create split file " & filename[1..find('.', filename)] &
sprintf("%d",splits))
close(source)
abort(0)
end if
-- Write split file
while (offset <= max*splits) and (offset <= size) do
puts(dest, getc(source))
offset = offset + 1
end while
-- Close split file
close(dest)
-- Exit if all done
if offset > size then
close(source)
exit
end if
-- Update splits file counter
splits = splits + 1
end while
-- Create batch file
dest = open("join.bat","w")
puts(dest,
"@ echo off\n" &
"cls\n" &
"echo Recreating " & filename & "\n" &
"@ echo off\n" &
"copy /b ")
for i = 1 to splits do
puts(dest, filename[1..find('.', filename)] &
sprintf("%d",i) & " ")
if i <= splits - 1 then
puts(dest, "+ ")
end if
end for
puts(dest, filename & " > nul\n")
close(dest)
puts(1,sprintf("%d",splits) & " split files created and join.bat\n")
-----< CODE END >-----
Hope this helps you. i tested it on a 2.2 MB zip file and worked
correctly (creating 2 splits).
Regards,
Daniel Berstein
danielberstein at usa.net
http://www27.pair.com/daber/architek