View previous topic :: View next topic |
Author |
Message |
SeeD
Joined: 03 Sep 2007 Posts: 2
|
Posted: Mon Sep 03, 2007 5:45 pm Post subject: Writing to file with Offset. How? |
|
|
Is there any way to write files with offset?
For example, I need to write value 01 in #2C5C
All I found was fileSeek function, but it`s not what I am looking for.
Sorry for my bad English and thanks in advance! |
|
Back to top |
|
|
ooPo Site Admin
Joined: 17 Jan 2004 Posts: 2032 Location: Canada
|
Posted: Mon Sep 03, 2007 8:05 pm Post subject: |
|
|
http://luanet.net/lua/function/seek
Quote: | function file:seek ( whence, offset ) |
Looks to me like you can do:
Code: | file:seek("set", 0x2C5C)
file:write(0x01) |
That doesn't work for you? |
|
Back to top |
|
|
SeeD
Joined: 03 Sep 2007 Posts: 2
|
Posted: Tue Sep 04, 2007 2:48 am Post subject: |
|
|
thank you for helping =)
here is my code
Code: |
file = io.open("test", "wb")
file:seek("set", 0x03)
file:write(0x01)
file:close()
|
test file before writing (HEX):
00 00 00 00 00 00 00
test file after LUA (HEX):
00 00 00 31
what should I use as an instance of file:write?
thanks again! |
|
Back to top |
|
|
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Sun Sep 09, 2007 1:35 pm Post subject: |
|
|
Use options "+r" |
|
Back to top |
|
|
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Sun Sep 09, 2007 6:58 pm Post subject: |
|
|
Just to clarify, you're using "wb" which opens a new file (deletes the old one) in binary mode. _________________ http://aaiiee.wordpress.com/
I can no longer do any homebrew PSP development nor discuss PSP specific topics. |
|
Back to top |
|
|
|