au lieu de me trimbaler avec 4 BMP, de la zik, et des datats, j'aimerais tout regrouper dans un fichier.
Quelle est l'approche la plus satisfaisante ?
Merci

===
PS : question sur ce forum et pas sur le forum anglais car je veux faire vivre le nôtre.
Code : Tout sélectionner
EnableExplicit
Procedure makeSomeFiles()
Protected out
Protected addr.i, file.s, leng.l
DataSection
IB01:
IncludeBinary "Data\image1.bmp"
IB02:
IncludeBinary "Data\image2.bmp"
IB03:
IncludeBinary "Data\image3.bmp"
IB04:
IncludeBinary "Data\musique1.mp3"
IB05:
IncludeBinary "Data\musique2.mp3"
IB06:
IncludeBinary "Data\musique3.mp3"
IB07:
IncludeBinary "Data\data1.txt"
IB08:
IncludeBinary "Data\data2.txt"
IB09:
EndDataSection
Structure ref
addr.i
name.s
size.i
EndStructure
NewMap files.ref()
DOSSIER.s="a l'endroi de ton choix, exemple C:\MonAPPLI\"
files("1")\addr = ?IB01
files("1")\name = DOSSIER + "image1.bmp"
files("1")\size = ?IB02 - ?IB01 ; get size of included binary
;
files("2")\addr = ?IB02
files("2")\name = DOSSIER + "image2.bmp"
files("2")\size = ?IB03 - ?IB02 ; get size of included binary
;
files("3")\addr = ?IB03
files("3")\name = DOSSIER + "image3.bmp"
files("3")\size = ?IB04 - ?IB03 ; get size of included binary
;
files("4")\addr = ?IB04
files("4")\name = DOSSIER + "musique1.mp3"
files("4")\size = ?IB05 - ?IB04 ; get size of included binary
;
files("5")\addr = ?IB05
files("5")\name = DOSSIER + "musique2.mp3"
files("5")\size = ?IB06 - ?IB05 ; get size of included binary
;
files("6")\addr = ?IB06
files("6")\name = DOSSIER + "musique3.mp3"
files("6")\size = ?IB07 - ?IB06 ; get size of included binary
files("7")\addr = ?IB07
files("7")\name = DOSSIER + "data1.txt"
files("7")\size = ?IB08 - ?IB07 ; get size of included binary
;
files("8")\addr = ?IB08
files("8")\name = DOSSIER + "data2.txt"
files("8")\size = ?IB09 - ?IB08 ; get size of included binary
;
ForEach files()
file = LCase(files()\name)
;Debug "key=" + MapKey(files()) + " : " + file
;Select Val(MapKey(files()))
; Case 1 To 3
; Default
; ;in=ReadFile(#FileNum, file, #PB_UTF8)
; ;If in : Continue : EndIf ; skip straight to the end of ForEach file()
; If fileExist(file) : Continue : EndIf ; skip straight to the end of ForEach file()
;EndSelect
;Debug "key=" + MapKey(files())
out=CreateFile(#PB_Any, file, #PB_UTF8)
If out
addr = files()\addr
leng = files()\size ; size of Included Binary
;Debug "addr=" + Str(addr)
;Debug "size=" + Str(leng)
WriteData(out, addr, leng)
CloseFile(out)
EndIf
Next
FreeMap(files())
EndProcedure
Code : Tout sélectionner
EnableExplicit
OnErrorGoto(?ErrorHandler)
Global AppPath$ = GetPathPart(ProgramFilename())
SetCurrentDirectory(AppPath$)
EnableDebugger
Declare makeMyDataFile()
Procedure makeMyDataFile()
Protected out
Protected addr.i, file.s, leng.l
Protected DOSSIER.s
Protected totalSize
DataSection
IB01:
IncludeBinary "Data\acm.chm"
IB02:
IncludeBinary "Data\addrview.chm"
IB03:
IncludeBinary "Data\AdvancedRun.chm"
IB04:
EndDataSection
Structure ref
addr.i
name.s
size.i
EndStructure
NewMap files.ref()
DOSSIER=".\"
files("1")\addr = ?IB01
files("1")\size = ?IB02 - ?IB01 ; get size of included binary
;
files("2")\addr = ?IB02
files("2")\size = ?IB03 - ?IB02 ; get size of included binary
;
files("3")\addr = ?IB03
files("3")\size = ?IB04 - ?IB03 ; get size of included binary
;
Protected mydatas.s="mydatas.dat"
out=CreateFile(#PB_Any, mydatas, #PB_UTF8)
If out
;on remplace le nombre magique du premier fichier inclus par 2 NUL
;En programmation informatique, un nombre magique est une valeur numérique ou textuelle constante
;utilisée pour identifier un format de fichier ou un protocole.
;Les nombres magiques sont les premiers octets d'un fichier qui sont propres à un type de fichier particulier.
WriteByte(out, 0)
WriteByte(out, 0)
ForEach files()
addr = files()\addr
leng = files()\size
totalSize+leng
WriteData(out, addr, leng)
Next
CloseFile(out)
EndIf
Debug "Taille totale: "+totalSize
Debug "Taille archive: "+FileSize(mydatas)
Debug "L'archive fait 2 octets de plus."
FreeMap(files())
EndProcedure
makeMyDataFile()
ErrorHandler:
End