Цитата ZaxBoys66:
; How to make fileread to read only "Content-Length" »
|
Код:
!include "TextFunc.nsh"
OutFile "content-length_test.exe"
Section
FileOpen $0 "$EXEDIR\File.txt" W
FileWrite $0 "HTTP/1.1 200 OK"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Date: Fri, 04 Sep 2015 07:27:00 GMT"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Server: Apache"
FileWriteByte $4 "13"
FileWriteByte $4 "10"
FileWrite $0 "Last-Modified: Wed, 24 Apr 2013 08:27:32 GMT"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 'ETag: "2b2e728-a38420-4db1712ca0d12"'
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Accept-Ranges: bytes"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Content-Length: 10716192"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Content-Type: application/octet-stream"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Expires: Sat, 05 Sep 2015 07:27:00 GMT"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "Connection: keep-alive"
FileClose $0
/*
FileOpen $0 "$EXEDIR\File.txt" r
FileRead $0 $1
FileRead $0 $2 ''
FileClose $0
MessageBox MB_OK "$1 $2"
*/
StrCpy $0 0
stGet:
IntOp $0 $0 + 1
${LineRead} "$EXEDIR\File.txt" "$0" $1
IfErrors 0 +2
MessageBox MB_OK|MB_ICONSTOP "error" idok error
StrCpy $2 "$1" 16
StrCmp $2 "Content-Length: " 0 stGet
StrCpy $2 "$1" "" 16
MessageBox MB_OK|MB_ICONINFORMATION "$2"
error:
SectionEnd
А если количество строк фиксировано и вы точно знаете, на какой строке будет эта запись - можно обойтись без чтения всего файла, а сразу указать нужную строку:
Скрытый текст
Код:
${LineRead} "$EXEDIR\File.txt" "6" $1
IfErrors 0 +2
MessageBox MB_OK|MB_ICONSTOP "error" idok error
StrCpy $2 "$1" 16
StrCmp $2 "Content-Length: " +2 0
MessageBox MB_OK|MB_ICONSTOP "error" idok error
StrCpy $2 "$1" "" 16
MessageBox MB_OK|MB_ICONINFORMATION "$2"
error: