CONST FilePointer = "<" + CHR$(35) + "FileStart" + CHR$(35) + ">"
CONST FilePointerEnd = "<" + CHR$(35) + "FileEnd" + CHR$(35) + ">"
DIM FileOne$ AS STRING
DIM FileTwo$ AS STRING
DIM FileWrite$ AS STRING
DIM Position AS INTEGER
DIM EndPosition AS INTEGER
DIM FileStream AS QFILESTREAM
SUB ConcealFile (FileOne AS STRING, FileTwo AS STRING, FileThree AS STRING)
IF FILEEXISTS(FileOne) THEN
IF FILEEXISTS(FileTwo) THEN
IF RIGHT$(FileThree,1) <> "\" OR RIGHT$(FileThree,1) <> "/" THEN
FileStream.OPEN(FileOne,fmOpenRead)
FileOne$ = FileStream.ReadStr(FileStream.Size)
IF TALLY(FileOne$,FilePointer) > 0 OR TALLY(FileOne$,FilePointerEnd) > 0 THEN
SHOWMESSAGE "There is a file already concealed in this file"
EXIT SUB
END IF
FileStream.CLOSE
FileStream.OPEN(FileTwo,fmOpenRead)
FileTwo$ = FileStream.ReadStr(FileStream.Size)
FileStream.CLOSE
IF TALLY(FileTwo$,FilePointer) > 0 OR TALLY(FileTwo$,FilePointerEnd) > 0 THEN
$ESCAPECHARS ON
SHOWMESSAGE "This file will not conceal correctly. We are sorry.\nThere will be future considerations to correct this."
$ESCAPECHARS OFF
EXIT SUB
END IF
FileStream.OPEN(FileThree,fmCreate)
FileStream.WriteStr(FileOne$,LEN(FileOne$))
FileStream.WriteStr(FilePointer,LEN(FilePointer))
FileStream.WriteStr(FileTwo$,LEN(FileTwo$))
FileStream.WriteStr(FilePointerEnd,LEN(FilePointerEnd))
FileStream.CLOSE
ELSE
SHOWMESSAGE ("File " + FileThree + " is invalid!")
END IF
ELSE
SHOWMESSAGE ("File " + FileTwo + " does not exist!")
END IF
ELSE
SHOWMESSAGE ("File " + FileOne + " does not exist!")
END IF
END SUB
SUB ExtractFile (FileOne AS STRING, FileTwo AS STRING)
IF FILEEXISTS(FileOne) THEN
IF RIGHT$(FileTwo,1) <> "\" OR RIGHT$(FileTwo,1) <> "/" THEN
FileStream.OPEN(FileOne,fmOpenRead)
FileOne$ = FileStream.ReadStr(FileStream.Size)
FileStream.CLOSE
IF TALLY(FileOne$,FilePointer) = 0 AND TALLY(FileOne$,FilePointerEnd) = 0 THEN
SHOWMESSAGE "No concealed file found!"
EXIT SUB
END IF
Position = RInstr(FileOne$,FilePointer) + LEN(FilePointer)
EndPosition = RInstr(FileOne$,FilePointerEnd) - 1
FileWrite$ = MID$(FileOne$,Position,EndPosition - Position)
FileStream.OPEN(FileTwo,fmCreate)
FileStream.WriteStr(FileWrite$,LEN(FileWrite$))
FileStream.CLOSE
ELSE
SHOWMESSAGE ("File " + FileTwo + " is invalid!")
END IF
ELSE
SHOWMESSAGE ("File " + FileOne + " does not exist!")
END IF
END SUB
|