flat assembler
Message board for the users of flat assembler.
Index
> Windows > The Very Simple Backup Program/File Monitor |
Author |
|
Matrix 17 Feb 2006, 21:03
use raid mirror...
so you don't have to make backups. |
|||
17 Feb 2006, 21:03 |
|
farrier 17 Feb 2006, 21:13
kake_zinger,
I just finished something like this for a customer! My program creates a thread, which uses FindFirstChangeNotification/FindNextChangeNotification along with WaitForSingleObject. I have it run in the AllUsers StartUp folder. It sits and waits for a file to be created in a certain folder and, when the file is closed by the program which created it, moves the file to the E:\ drive into a folder created by my program with the name YYYYMMDDDOW. For instance, todays folder would be 20060217FRI. This could be modified to do what you want. hth, farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
17 Feb 2006, 21:13 |
|
LocoDelAssembly 17 Feb 2006, 23:32
I was trying to do the same thing but because I have little time and some things to finish before I did't implemented anything but I read in the SDK that there is another funtion to monitor changes, the ReadDirectoryChangesW API function.
Requirements Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0. Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0. Header Declared in Winbase.h; include Windows.h. Library Link to Kernel32.lib. DLL Requires Kernel32.dll. I prefer this one because this function tells you which file was modified also and which kind of modification. Note that with this function is more easy to detect file renamings. Regards, HernĂ¡n |
|||
17 Feb 2006, 23:32 |
|
kake_zinger 18 Feb 2006, 12:34
farrier, thank you very much indeed.
Could I interest you in refining the program just a little bit so that it would ask or take an argument about the paths what it backs up and where? Just a simple version of a single directory to choose would do fine. Of course it'd be superb if it could be turned into a list of directories or even a recursable directory tree. But this is really beyond the scope of a "simple" program. You know, turning it into a general utility program of this kind. It would really benefit everybody and come into a real need because there is no versioning or constant backup in Windows. If you're not interested in refining it it's all ok, I just don't to Windows myself and I'd like you to get credit for your own programming especially since you have done this already. Good programming ideas are not that many. |
|||
18 Feb 2006, 12:34 |
|
farrier 07 Mar 2006, 05:24
locodelassembly,
thanks for the idea about using ReadDirectoryChangesW, it seemed like a good idea. I figured it shouldn't be too hard to make it work! Well, it wasn't easy for me. But, I've got something working. When a Change is detected, an array of FILE_NOTIFY_INFORMATION structures is created, reporting the File which has changed and the change which has occurred. The only thing I could not get a report for was when a file is renamed. I got a report for the OldName but not the NewName. I think I did not process the array properly, and I may look at this some more, maybe. What this program does is Watch the folder/directory from which the program is run, and reports any file changes which occur in the folder. The buttons on the tool bar will: Create a file; Delete a file; Modify a file; Rename a file using Movefile; Move a file from the app's folder to the root of it's drive Move a file--after creating it--from the root of the app's drive to the app's folder Results are logged to a ListView, some things are not reported, like when a file is recreated after it is deleted. hth, farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
07 Mar 2006, 05:24 |
|
LocoDelAssembly 07 Mar 2006, 12:17
Since I cannot compile you project because I don't have some of the include files I guess the error is this:
Code: .if edi, ne, 0 add ebx, edi mov edi, [ebx] .endif .until edi, e, 0 You will always skip the last record because you load to EDI the next record and since the ".until" uses EDI you exit from the loop before processing the last record. A solution could be fixing the following parts like this: Code: push ebx push edi push esi lea ebx, [bufRDCW] .repeat mov edi, [ebx] And replace this: Code: .if edi, ne, 0 add ebx, edi mov edi, [ebx] .endif Code: add ebx, edi Hope this works Regards, LocoDelAssembly |
|||
07 Mar 2006, 12:17 |
|
farrier 07 Mar 2006, 18:38
locodelassembly,
YES! I looked at that loop for 2 hours last night and didn't see that! Thanks!! That fixed one of two problems which kept the NewFileName from being displayed. I have a flag--gListAct--used to not display the actions I took to replace files I had modified or deleted. After the MoveFile command, I changed gListAct to stop the display, but the code to display the OldFileName got executed, and the flag gets changed before the code to display the NewFileName got executed. I put in a timer delay after the FCRename code is executed, when the timer expires, I replace the original file and delete the renamed file. Try the attached files. The only "non-standard" include file--GlobalMem.inc--is from the Fresh project, and allows us to split up the initialized--iglobal--and uninitialized--uglobal--data to be declared in multiple files, but the separate data declarations are gathered into one segment. That helps me a lot when I use multiple .asm files. Thanks to the Fresh project! Thanks again for your help!! farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
07 Mar 2006, 18:38 |
|
farrier 07 Mar 2006, 20:46
Someone on the MASM32 site asked about an app which blinked an LED on screen to match the Disk Drive access light. I adapted the ReadDirectoryChangesW to do this in a crude way, by showing the old fashioned rotating cursor in the window title bar.
farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
07 Mar 2006, 20:46 |
|
LocoDelAssembly 07 Mar 2006, 20:59
farrier, you didn't posted the include files I need. Well GlobalMem.inc I can get it from Fresh but, what about \CSCSC\Working\DateBack\Utilities.asm ?
Regards, LocoDelAssembly PS: Well now I don't see GlobalMem.inc in my Fresh so post it too. |
|||
07 Mar 2006, 20:59 |
|
farrier 08 Mar 2006, 00:05
locodelassembly,
I'm sorry to make this so difficult, attached are the two files. The macros for iglobal and uglobal have changed since I started using them. Again, thanks for your help! farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
08 Mar 2006, 00:05 |
|
LocoDelAssembly 08 Mar 2006, 03:46
Well I'm not sure what problem are you talking about but letting the program to display all the monitored events I can see that the program correctly catches all of them
When I let the program check the flag first well, the buttons "move from" and "move to" never display anything and the button "create" some times works, some times don't, I can't get what is required to do first in order to get the creation displayed. Anyway I think that the monitoring stuff is working great, I'd tested creating, renaming and deleting files and folders using Windows and those events were displayed too . I'd tested with monitoring subdirectories enabled and the program had displayed the events showing the relative paths Thanks to you for posting this code, now I know that it works great Regards, LocoDelAssembly |
|||
08 Mar 2006, 03:46 |
|
farrier 08 Mar 2006, 08:37
locodelassembly,
With the help of your inspiration and help! Thanks again! Create is pretty straightforward, the MoveFrom and MoveTo move from and to the _Root and the app's folder, you may have adjust the value of _Root in order for button commands to work. farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
08 Mar 2006, 08:37 |
|
Crukko 10 Apr 2006, 11:48
Is there a doc file with info about prg and features?
Thx! |
|||
10 Apr 2006, 11:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.