First of all. If the file exists the open method must return ReturnCode::OK. I understand that the file does not exist and you are asking why the resolve method is returning OK. If I understand it wrong, please, ask again.
Now.
You are right.
DIALOG22.txt can even not exist at all, and the return code will be OK.
In GledSave you can resolve files, even if they do not exist, because you resolve them before creating them or before opening them.
GledSave was desing to fulfill more than a simple file system. This abstraction let you handle any file in any file system in the same way. This aproach makes possible to add ftp or other network filesystem. We have not yet implemented them but they will be introduced in a near future.
For example in an ftp filesystem when you resolve the file you set the connection values (ip, user, password). Then the open method try to start the connection.
Also i want to make a remark in the ReturnCode enumeration from GledPlay. You are reading the description that windows get from the return value ("The system cannot read from the specified device." ) This has nothing to do with GledPlay, you must compare with the ReturnCode:: enumerator. The correct value for your example will be ReturnCode::ERROR_OPENING_FILE
At last, I will make an example to show the benefits in coding process that GledSave introduces and the power of this abstraction.
The first code will show you how to acceses two files, a text file and an image in a directory located in c:\.
- Code:
FileSystemManager fsm;
HRESULT returnCode;
File root;
File textFile;
File imageFile;
if ( (returnCode = fsm.resolveFile(&root;, TEXT("c:\\ testfolder"))) != ReturnCode::OK ) {
// you must handle the error.
}
if ( (returnCode = root.resolveFile(&textFile;, TEXT("banner.txt"))) != ReturnCode::OK ) {
// again, handle the error.
}
// you do what you want with your file
// you must open it first.
if ( (returnCode = root.resolveFile(&imageFile;, TEXT("image.png"))) != ReturnCode::OK ) {
// again, handle the error
}
// you do what you want with your files.
Now you want to package all your files in a zip, you just have to change very little in your code, watch..
- Code:
FileSystemManager fsm;
HRESULT returnCode;
File root;
File textFile;
File imageFile;
if ( (returnCode = fsm.resolveFile(&root;, TEXT("zip:c:\\testfolder.zip"))) != ReturnCode::OK ) {
// you must handle the error.
}
if ( (returnCode = root.resolveFile(&textFile;, TEXT("banner.txt"))) != ReturnCode::OK ) {
// again, handle the error.
}
// you do what you want with your file
// you must open it first.
if ( (returnCode = root.resolveFile(&imageFile;, TEXT("image.png"))) != ReturnCode::OK ) {
// again, handle the error
}
// you do what you want with your files.
As you can see, you only have to change the path to a zip. All the others calls in the exmaple keep the same.
In the future you will be able to do the same with ftp. You will only have to get the root of the ftp and that´s all.
Or maybe better, you will change the source of your files dynamically on user commands (change the ftp or switch between ftp and zip files), and your code will keep perfectly nice.
If you have any doubts, or I wasn´t clear enough please, ask as many times as you want.
See you
Matias Saguir