|
ok, I understand.
But this library is very old and not compiling,one of header file is missing.
Do we have any other Library for serialization Except Boost ?
Thanks For your Reply.
Regards
Y
|
|
|
|
|
There are probably but I have always used my own creatures for this kind of task so I can't recommend you a good and (I guess) free solution if you don't like boost. Long ago when I checked out the available solutions and I didn't really liked them. Maybe the others can recommend you one or you can use google to search for something that meets your requirement. As a final solution you can write your own framework that is a fun way to learn something new if you have the time and interest.
|
|
|
|
|
Thanks Dear
In case of using AutoSerial, Do I need to include only AutoSerial.h ?
or Something else I need to do. I didn't get from this Docs.
Thanks Once Again.
Regards
Y
modified 31-Jul-13 8:35am.
|
|
|
|
|
You are welcome! Unfortunately I cannot answer this as I used it only once long ago.
Serialization in C++ is a difficult topic. Every solution is messy as serialization isn't really supported by the language. In my opinion it would be very useful to have a bit more detailed runtime type info support in C++ that can be used for serialization. On detailed runtime type info I mean for example auto-generated list of struct/class members, member names, enum member list/member names, ........ On top of such info (that I'm currently putting together manaully in my serialization system) it is quite easy to write reasonably simple yet effective serializers.
I would give boost::serialization a try, that is a quite popular and maintained library.
|
|
|
|
|
Ok, But Boost::Serialization seems to me a heavy library.
It wud be better to have one own and fun to learn a new framework.
Anyway, thanks Buddy For all your replies.
Regards
Y
|
|
|
|
|
You are welcome! I'm also using my own solution because its quite lightweight and provides only a few features I need in a better way. Good luck with creating your own stuff and have fun! Don't forget to take a look around to check out the source code of some existing frameworks to steal good ideas before starting out with your own stuff!
|
|
|
|
|
Are overlapped file writes guaranteed to happen in the order in which they are issued? (On Windows)
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
No.
Although the IRP requests are generally dispatched from a FIFO queue... a call to WriteFile [^] results in a IRP_MJ_WRITE[^] request being sent from the i/o manager down through the filter manager and associated minifilter stack. If any installed legacy, FS or filter driver return STATUS_PENDING for your write request... this would potentially allow other i/o requests to complete out-of-order.
Best Wishes,
-David Delaune
|
|
|
|
|
Wow, thanks. I'm glad you were around to answer this with your knowledge of the driver stack.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Even if the current implementation on your windows version/installation guarantees this order you shouldn't exploit it (for example because this implementation may change in the future if the documentation doesn't explicitly state that it wont). Generally in case of async operations (not only in case of file IO) you shouldn't assume any order in which the async tasks are completed. If an async system doesn't have to guarantee completion order than it has more freedom to perform optimizations. If you have to process the completed async requests in a specified order then its relatively easy to make the result processing ordered.
|
|
|
|
|
Thank you.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello ,
Is it possible to create a empty file with predefined size of that file.
please reply me soon ...
Regards
Sarfaraz
|
|
|
|
|
Maybe it is just me but I think the predefined size of an empty file is zero. Maybe this is something you are looking for: SetEndOfFile()[^]
|
|
|
|
|
How to create the the empty file with defined size in c++ or MFC.
thanks for reply .
see i am looking to create a file that should be empty and should not have data inside the file.
you can say acquiring memory space from the particular drive ..
Thanks
|
|
|
|
|
This is the easiest. Open/Create a new file and then close it immediately without writing into it. That's it.
|
|
|
|
|
ya i agree what about the size which i want to define think that around 1gb or 100 mb ..
thanks
|
|
|
|
|
OK, it is time to decide: Do you want an empty file or one that is 1gb large???
|
|
|
|
|
large file without any data inside the file .
look what actually looking to do is to create a large file with define size.
|
|
|
|
|
A file is either empty or large. It can not be both.
|
|
|
|
|
When you say 'empty', do you really mean a file filled with 0's or 1's?
|
|
|
|
|
Read the documentation of SetFilePointerEx()[^], SetEndOfFile()[^] and SetFileValidData()[^] - these are the functions you need along with CreateFile()[^] and CloseHandle()[^].
Create a file with CreateFile(), set the file pointer with SetFilePointerEx() and then call SetEndOfFile(). As a last step close the file with CloseHandle(). This is how you preallocate a file on windows. Note that the preallocated file data will be overwritten with zeros by windows in order to prevent you from reading the previous contents of the files that were stored on these sectors before deletion/moving. If you want to ask windows to skip the overwrite with zeros (for example to save time because in case of big preallocation its time consuming) then you need a few privileges and a SetFileValidData() call. Read the function documentations and use google to find out how to do that trick.
|
|
|
|
|
ok. i think its not possible to have empty file except filled with zeros...
Thanks every body for your replies.
Looking to make app that lock the usb data but am unable to start any idea or guidance
will be appreciated .
regards
sarfaraz
|
|
|
|
|
Hi,
Yes, you can create 'empty' files of 1GB size.
If you are on Microsoft Windows XP or above and using an NTFS file system then you can create a sparse file. This will allow you to create 'empty' files of any size that contain 'virtual zeros'. The Windows operating system will report the file as having a valid file size... and it will even apply to user disk quota.
Sparse Files[^]
Steps to create a sparse file:
1.) Call CreateFile [^]and create a new file. Keep the file handle open.
2.) Call DeviceIoControl [^] on your open file handle with the FSCTL_SET_SPARSE control code[^] to mark the file as sparse.
3.) Call the SetFilePointerEx function[^] to move from FILE_BEGIN past the end of file. Make sure to assign liDistanceToMove argument to the desired file size.
4.) Call the SetEndOfFile function[^] to set the EOF to the current position of the file pointer.
5.) Close your file hande.
Best Wishes,
-David Delaune
|
|
|
|
|
No and yes.
No, insofar as the file must contain some data. The data will be meaningless, but it will be there all the same.
Yes, in that you can create a file that occupies 1GB without explictly writing 1gb of data to it. I write a single byte after settiing the file-pointer. This is enough to create the file with the desired size. It takes just as long to run for 1024 bytes as it does for 1024 megabytes.
Code:
#include <stdio.h>
int main()
{
FILE *fp;
const int numMegabytes = 1024; int numBytes = (numMegabytes * 1<<20);
fp = fopen("myFile.dat", "wb");
fseek(fp, numBytes-1, SEEK_END); fwrite("\0", 1, 1, fp); fclose(fp);
return 0;
}
"Science adjusts its views based on what's observed. Faith is the denial of observation, so that belief can be preserved." - Tim Minchin
|
|
|
|
|
The std solution. I tricked one of my friends in the old DOS times with an autoexec program that always filled up the hard drive free space at startup. In DOS this trick created only a chain in the FAT without actually filling up the space so it was very quick.
|
|
|
|