EldoS | Feel safer!

Software components for data protection, secure storage and transfer

CAllbackFS: sample crashes

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#5917
Posted: 04/17/2008 07:18:28
by Volodymyr Zinin (EldoS Corp.)

Security processing is optional. So comment the following:
mCbFs.OnGetFileSecurity = new CbFsGetFileSecurityEvent(CbFsGetFileSecurity);
mCbFs.OnSetFileSecurity = new CbFsSetFileSecurityEvent(CbFsSetFileSecurity);
#5918
Posted: 04/17/2008 07:20:28
by Volodymyr Zinin (EldoS Corp.)

Quote
Robin Astle wrote:
When I open the directory readwrite I can safe word files correctly when I map a local folder. But then I can't browse the network share anymore.

So the issue of saving word files is that in my project The OpenFile on a directory is read only as you suggest, but that prevents me from opening and saving word files.

The problem is in the sample application. We will correct it in the next build.
#5944
Posted: 04/21/2008 05:41:04
by Robin Astle (Basic support level)
Joined: 04/15/2008
Posts: 30

I found the issue, and by this, a question.

The cause of the problem:
The GetFileInfo event uses this function:
Code
SafeFileHandle hFile = CreateFile(mRootPath + FileName, (FileAccess)READ_CONTROL, 0, IntPtr.Zero, FileMode.Open, FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero);


the handle returned was invalid when this method was called for the temporary word file ~WRL0001.tmp
I noticed that this file is from a dll import, so I changed the code to the following:

Code
FileInfo fi = new FileInfo(mRootPath + FileName);
            if (fi.Exists)
            {
                FileExists = true;
                CreationTime = fi.CreationTime;
                LastAccessTime = fi.LastAccessTime;
                LastWriteTime = fi.LastWriteTime;
                EndOfFile = fi.Length;
                AllocationSize = fi.Length;
                FileAttributes = (uint)fi.Attributes;
            }
            else
            {
                //throw new IOException("Could not GetFileInformationByHandle.", new Win32Exception());
                FileExists = false;
            }


And I can now successfully save Word files on the network share.

2 Questions now arise:

With the C# API I don't know how to get the AllocationSize, so I returned the file length, is this a problem?

Second question: is there a reason the sample application does not uses the C# API for this?
#5945
Posted: 04/21/2008 06:13:42
by Volodymyr Zinin (EldoS Corp.)

Quote
Robin Astle wrote:
With the C# API I don't know how to get the AllocationSize, so I returned the file length, is this a problem?

It's ok. You can return file size instead of allocation size.

About file sizes I recently posted an explanation here
Quote
There are two file sizes exist. One of them is 'end of file' (i.e. EOF) that means real size of data in a file. The other is 'allocation size' - it's size of space that a file has on a disk.
Before writing to a file (if space on a storage has not been allocated yet) and sometimes at a file creation time (see the ZwCreateFile's parameter AllocationSize in MSDN) the callback OnSetAllocationSize is called and if it returns success then CallbackFS (other file systems work in the same way) is assured that enough space on a disk has been allocated for data that will be written to the file. And when a file is closed and its 'allocation size' is more then 'end of file' then the file system frees excess space (by calling OnSetAllocationSize again).
#5946
Posted: 04/21/2008 06:15:59
by Volodymyr Zinin (EldoS Corp.)

Quote
Robin Astle wrote:
Second question: is there a reason the sample application does not uses the C# API for this?

No, there is not any reason.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 11692 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!