forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Writing to file with Offset. How?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
SeeD



Joined: 03 Sep 2007
Posts: 2

PostPosted: Mon Sep 03, 2007 5:45 pm    Post subject: Writing to file with Offset. How? Reply with quote

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
View user's profile Send private message
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Mon Sep 03, 2007 8:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
SeeD



Joined: 03 Sep 2007
Posts: 2

PostPosted: Tue Sep 04, 2007 2:48 am    Post subject: Reply with quote

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
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sun Sep 09, 2007 1:35 pm    Post subject: Reply with quote

Use options "+r"
Back to top
View user's profile Send private message
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Sun Sep 09, 2007 6:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group