dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AIR FileSystem troubles

  1. #1
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379

    AIR FileSystem troubles

    I've been trying to write this simple AIR application for a client but I'm stumbling on storing certain settings persistently (shared object is not an option). It's been requested that I use INI files which I'm quite comfortable with. The problem is that in writing my INI editing class I came across an issue. Standard INI files use a syntax similar to the following:

    Code:
    [user settings]
    moviedir=C:\Users\Public\Videos
    imagedir=C:\Users\Public\Images
    I've written a working get function to retrieve the value of any key in any section in the file, but I can not get my set function to work properly because what I'd like to do is just overwrite the rest of the line from the right of the equal sign for any key I'd like to change. The problem is that the FileStream.position member works by counting bytes from the start of the file, unlike other languages where you can set a line number to be start writing on.

    Also, I cannot simply search the contents of the file and return the position of the key and use that in place of the position member because different sections of the INI file have similar keys. Does anyone know of a way I might be able to overwrite just the portion to the right of the equal sign (or the whole line) or a way to get the starting byte index of the line itself without having to delete/rewrite the whole file?
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  2. #2
    Junior Member
    Join Date
    Jul 2006
    Posts
    28
    when you already know the structure of your file.
    [user settings] -> dosent change
    moviedir= -> dosent change
    imagedir= -> dosent change

    so just read the entire thing... form the string in memory with new value and write back to file

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center