EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Copying vs. creating a file

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#5625
Posted: 03/26/2008 11:16:13
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Hello, again.

In my application I want to be able to detect whether or not a new file that is being created is actually a new file and not a file that is being copied. What I mean is this, if you are in Windows Explorer and you right click on the right pane, you get a context menu that allows you to create a new document, say a text or Word file. On the other hand, you can also drag and drop files onto a folder, which on effect creates a new file in that folder that is a copy of the old file.

I want to be able to distinguish between those two cases so that my application can do the correct things in each case. Do you have a suggestion as to how I distinguish between those cases?

I am at this point fairly familiar with your VDisk sample but I am not sure as to whether it distinguishes between those two cases and if it does how it does it.




#5626
Posted: 03/26/2008 11:32:26
by Eugene Mayevski (EldoS Corp.)

Sorry for disappointing you, but there's no such atomic operation as file copy. Every copy is done by writing new file.


Sincerely yours
Eugene Mayevski
#5627
Posted: 03/26/2008 11:40:43
by Volodymyr Zinin (EldoS Corp.)

Perhaps it's possible by writing shell extension dll.
#5628
Posted: 03/26/2008 12:05:47
by Eugene Mayevski (EldoS Corp.)

Explorer would be just one of many applications (although probably the most popular). But indeed there exist so-called ICopyHook interface that would help in creating such shell extension.


Sincerely yours
Eugene Mayevski
#5629
Posted: 03/26/2008 12:18:30
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I guess my question was misunderstood.

What I really need is the open flags that are being used when opening the file. In UNIX these flags are specified on the open as things like O_RDONLY or O_CREAT. In Windows you see them on the open as a string like "w" for write, "r" for read, "a" for append, etc. Now I did see that you pass the file attributes in and there is a FILE_ATTRIBUTE_RDONLY that gives me the O_RDONLY flag, but in looking over the Windows .h file for those attributes I didn't see all of the others that I was expecting.
#5630
Posted: 03/26/2008 12:36:07
by Eugene Mayevski (EldoS Corp.)

FILE_ATTRIBUTE_READONLY is the attribute of the file, it's not an opening mode.
The open modes are described in MSDN in CreateFile() function description. They are CREATE_ALWAYS, CREATE_NEW etc.
Is this what you were looking for?


Sincerely yours
Eugene Mayevski
#5631
Posted: 03/26/2008 12:46:34
by Volodymyr Zinin (EldoS Corp.)

Windows supports POSIX standard. So you can also use the file i/o functions like in Unix. Their prototypes are declared in stdlib.h, stdio.h, fsctl.h
#5632
Posted: 03/26/2008 13:03:02
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Quote
Eugene Mayevskiwrote:
FILE_ATTRIBUTE_READONLY is the attribute of the file, it's not an opening mode.
The open modes are described in MSDN in CreateFile() function description (http://msdn2.microsoft.c­om/en-us/library/aa363858­(en-us,VS.85).aspx). They are CREATE_ALWAYS, CREATE_NEW etc.
Is this what you were looking for?


Yes, but in your VDisk program you are doing the CreateFile for the testfile_1.txt file, but if someone else creates a new file, that someone else is doing the CreateFile, whoever it is, it may be the Windows Explorer program itself. I want to know, if I can, the flags they used on the CreateFile that they are doing. Is that passed in to your callback functions anywhere?
#5633
Posted: 03/26/2008 13:18:54
by Eugene Mayevski (EldoS Corp.)

I am sorry but I tried to read your text 4 times but I don't understand it. I am still guessing, what you are trying to figure out.


Sincerely yours
Eugene Mayevski
#5634
Posted: 03/26/2008 13:39:54
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

OK, I will try again to explain myself better.

I am trying to create something that is like your VDisk or your mapper sample. In effect I want to have a virtual drive that the user can see in Windows Explorer and do with it whatever he would normally do on a real drive. So, for example, he should be able to create new files, open old files, drag and drop files from and to my virtual drive, etc.

But, instead of that drive pointing to a real drive, I want to catch whatever the user is trying to do and do the necessary things using my database system to emulate what he is trying to do. So again, for example, if he is trying to open a file I want to call my subroutine that emulates opening files. My subroutine that emulates opening files is fairly sophisticated and like the Windows CreateFile routine, it also has flags like CREATE_NEW, OPEN_EXISTING, GENERIC_READ, etc. (although in my API the flags have different names). I need to make decisions about which of these flags to set when the user does whatever it is he does.

I noticed in your mapper sample, that you make certain decisions about what flags to use on the CreateFile call, but the decisions you make seem to be fixed and not dependent upon what the user is doing. I want to make sure that I emulate exactly what the user is trying to do. So, for example, if he is trying to open a file for Read Only access, I want to make sure I call my open emulation subroutine with the Read Only flag.

Does this explanation make things any clearer?
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 10861 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!