Hi all

can anybody shed some light on how to add 2 or more binary files together.
Under dos I think that you used to use the copy command with some switches but I have forgotten and cannot find any info anywhere.

Cheers
fiddler
:grin:
Posted on 2001-08-09 01:43:32 by fiddler
Hi, in a dos box type

copy /b file1+file2[+...fileN]

file2 gets appended to the end of file1
if newfilename isn't specified then file1 gets overwritten

/b is used to indicate binary file(s). iF ascii files then use /a
you can mix ascii and binary files like this

copy /b file1 + file2 /a + file3 /b + file4 newfilename
hope that helps

actually in a dos window type copy /?
this should give some info

the MArtial
Posted on 2001-08-09 02:14:05 by MArtial_Code
Is there a command to extract the file back into the separate files?
Posted on 2001-08-09 13:22:49 by Will
You can use this function for splitting. It's from the heart of one of my Apps nd has some useless code in it, wich you don't need. But I'm sure, this pushes you in the correct direction :grin:


SplitFile proc hParent:DWORD, lpDir:DWORD, lpFile:DWORD, lpSplit:DWORD

cmp byte ptr [lpHtml], 1
jne @F
invoke wsprintf, addr szHtmlPathBuffer, addr szOutputMask, \
lpDir, addr szOutputNameBuffer, addr szHtmlFile
invoke CreateFile, addr szHtmlPathBuffer, GENERIC_WRITE, 0, 0, \
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
mov hHtml, eax
invoke WriteFile, hHtml, addr szHtmlStart, sizeof szHtmlStart, \
addr hWritten, 0
invoke WriteFile, hHtml, addr szHtmlNewLine, 2, addr hWritten, 0
@@:

invoke CreateFile, lpFile, GENERIC_READ, FILE_SHARE_READ, 0, \
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0
mov hFile, eax ; handle der ge?ffneten datei speichern

invoke GetFileSize, hFile, 0
mov hSize, eax ; dateigr?sse speichern

invoke GlobalAlloc, GHND, hSize
mov hMem, eax ; speicher reservieren

invoke GlobalLock, eax
mov pMem, eax ; pointer bekommen

invoke ReadFile, hFile, pMem, hSize, addr hRead, 0 ; datei lesen

mov esi, pMem ; buffer
mov ecx, hSize ; gr?sse
mov al, 84 ; mit was xor'en
xorit:
xor [esi], al ; eine super encryption :-)
inc esi
loop xorit

invoke atodw, lpSplit ; ascii to dword
mov ecx, 1000
mul ecx ; eax * ecx
mov lpSize, eax

mov eax, 0
mov lpX, eax ; lpX auf null setzen

mov eax, hSize
mov ecx, lpSize
div ecx
shl eax, 16 ; gr??e in high word schieben
invoke SendMessage, hProgressBar, PBM_SETRANGE, 0, eax

invoke GetTickCount
mov lpTimerStart, eax

.while hSize != 0
inc lpX ; counter erh?hen

.if lpX <= 9 ; wir wollen f?hrende nullen haben
invoke wsprintf, addr szlpX, addr sz00Null, lpX ; 001
.elseif lpX <= 99
invoke wsprintf, addr szlpX, addr sz0Null, lpX ; 010
.elseif lpX <= 999
invoke wsprintf, addr szlpX, addr szNull, lpX ; 100
.else ; h?her als 999
invoke MessageBox, hParent, addr szCountErrorMsg, \
addr szErrorCaption, MB_ICONERROR
dec lpX
.break
.endif

invoke wsprintf, addr szOutputBuffer, addr szOutputMask, lpDir, \
addr szOutputNameBuffer, addr szlpX ; dateinamen

mov eax, lpSize

.if hSize <= eax ; wenn wir am ende der datei sind ...
invoke CreateFile, addr szOutputBuffer, GENERIC_WRITE, 0, 0, \
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
push eax
invoke WriteFile, eax, pMem, hSize, addr hWritten, 0
; ... schreiben wir den rest rein
pop eax
invoke CloseHandle, eax

cmp byte ptr [lpHtml], 1
jne @F
invoke wsprintf, addr szHtmlTableBuffer, \
addr szHtmlTable, \
addr szOutputNameBuffer, addr szlpX, \
addr szOutputNameBuffer, addr szlpX
invoke WriteFile, hHtml, addr szHtmlTableBuffer, \
sizeof szHtmlTableBuffer, \
addr hWritten, 0
invoke WriteFile, hHtml, addr szHtmlNewLine, 2, \
addr hWritten, 0
@@:

.break
.endif

invoke CreateFile, addr szOutputBuffer, GENERIC_WRITE, \
0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0

push eax
invoke WriteFile, eax, pMem, lpSize, addr hWritten, 0
pop eax
invoke CloseHandle, eax

cmp byte ptr [lpHtml], 1
jne @F
invoke wsprintf, addr szHtmlTableBuffer, \
addr szHtmlTable, \
addr szOutputNameBuffer, addr szlpX, \
addr szOutputNameBuffer, addr szlpX
invoke WriteFile, hHtml, addr szHtmlTableBuffer, \
sizeof szHtmlTableBuffer, \
addr hWritten, 0
invoke WriteFile, hHtml, addr szHtmlNewLine, 2, addr hWritten, 0
@@:

mov eax, lpSize
sub hSize, eax ; size verkleinern
add pMem, eax ; pointer verschieben

invoke SendMessage, hProgressBar, PBM_DELTAPOS, 1, 0
.endw

invoke GetTickCount
sub eax, lpTimerStart
push eax

invoke GlobalUnlock, pMem ; speicher freigeben
invoke GlobalFree, hMem

cmp byte ptr [lpHtml], 1
jne @F
invoke WriteFile, hHtml, addr szHtmlEnd, sizeof szHtmlEnd, \
addr hWritten, 0
invoke WriteFile, hHtml, addr szHtmlNewLine, 2, addr hWritten, 0
invoke CloseHandle, hHtml
@@:

invoke CloseHandle, hFile

invoke SendMessage, hProgressBar, PBM_SETPOS, 0, 0

pop eax
xchg eax, ecx
mov eax, lpX
ret
SplitFile endp
Posted on 2001-08-09 15:05:00 by bazik