Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » File locking and Serialization
File locking and Serialization [message #36237] Wed, 16 May 2012 00:46 Go to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi,

I am realising that I don't really know how File Streams and Serialization works.

In UPP is there a mechanism to lock a file while my app runs and then release it when I either close the app or load a new file please?

Also, there isn't much of a preamble to the Serialization section in the documentation. I thought I knew how that works but some of my users tell me that sometimes when openWind crashes it mangles the file that it was loaded from. This makes me think there might be more to Serialization than I realise. Or are they making it up? Smile

Cheers,

Nick



Re: File locking and Serialization [message #36240 is a reply to message #36237] Wed, 16 May 2012 09:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Nixnixnix

AFAIK U++ serialization classes only touch the files when you call the Load... (for reading) and Store... (for writing) functions.

Personally I prefer Xmlize and Jsonize over Serialize because they are more robust to class changes and because it is very easy to check problems. If I do not want the user to read the file I just encrypt it. If it is too large I zip it (before encrypting it Smile).

Now, what happen if more than one user can access a ...lize file at the same time for reading and writing... IMHO you leave them at their fate.

I think in that case you should design a blocking system.


Best regards
IƱaki
Re: File locking and Serialization [message #36243 is a reply to message #36237] Wed, 16 May 2012 12:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Tue, 15 May 2012 18:46

Hi,

I am realising that I don't really know how File Streams and Serialization works.

In UPP is there a mechanism to lock a file while my app runs and then release it when I either close the app or load a new file please?

Also, there isn't much of a preamble to the Serialization section in the documentation. I thought I knew how that works but some of my users tell me that sometimes when openWind crashes it mangles the file that it was loaded from. This makes me think there might be more to Serialization than I realise. Or are they making it up? Smile



Well, this is only likely if it crashes during Serialize, or if Serialize has done something wrong before (and perhaps it crases BECAUSE files are mangled).

About locking, FileOut (used by serialization) is locking the output file by default.
Re: File locking and Serialization [message #36250 is a reply to message #36243] Wed, 16 May 2012 18:00 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks Koldo and Mirek, that is what I thought.

If there is no way to lock a file without having it open (which would seem to invite problems) then I can just write another file to disk to stop it being read I guess. Just wondered if there was something more sophisticated already in UPP.

Thanks,

Nick
Previous Topic: Custom array Jsonize
Next Topic: CParser: proposal of new functions
Goto Forum:
  


Current Time: Thu Apr 18 08:37:28 CEST 2024

Total time taken to generate the page: 0.01276 seconds