Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Folder watch
#1
Hi Gintaras, hi all

1.

I have a special situation to handle; in a specific folder, I have several folders.

A certain program I use converts folders as junctions, keeping same names.

I need to act when folders become junctions, and when junction revert to folders when program ends.

I set up a file trigger, and it works on detecting those changes.

But what is the correct code to detect each change.

sel event
case [1,2,4,8 (i don't know what to use there)]: do action when junction created
case [1,2,4,8 (i don't know what to use there)]: do action when folder recreated


Here is the problem, i can't find the way to implement that step.
2.

Can't you check the thread on disk insertion (17th of august) and tell me if you have an idea?

I need to retreive disk information especially the information in
\Harddisk1\partition1 form

Thanks.
#2
1. I don't know, difficult to test when I don't have the program. In the file-triggered macro add out F"{event} {name}" to see what happens.

2. I guess maybe can be used Windows API function DeviceIoControl. Or WMI. Look in stackoverflow . com etc. What you will do with \Harddisk1\partition1 form?
#3
1. The event raised by F"{event} {name}" is eight each time.
How can I test to see if the resulting name points to a folder or a junction (only those types, not files and so on).
If i could tell by test, i'll be able to act depending on the type (folder => action A, junction => action B)

2. I'd like to interact with the program, and it's command line only interpret disks/partitions in \harddisk{number}\partition{number}
#4
1. I cannot answer, try to find in google. Also try this:
Macro Macro1820
Code:
Copy      Help
int attr=GetFileAttributesW(@fullPathOfTheFolder); if(attr=-1) end "failed, %s" 0 _s.dllerror
if(attr&FILE_ATTRIBUTE_REPARSE_POINT) out "is junction"
Google suggestions:
Hard Links and Junctions
Reparse Point Operations

2.
Macro Macro1817
Code:
Copy      Help
str driveLetter="C"

__Handle hf=CreateFileW(@F"\\.\{driveLetter}:" 0 0 0 OPEN_EXISTING 0 0); if(hf=-1) end "failed, %s" 0 _s.dllerror ;;note: this just gets handle, not creates a file

STORAGE_DEVICE_NUMBER d
if(!DeviceIoControl(hf IOCTL_STORAGE_GET_DEVICE_NUMBER 0 0 &d sizeof(d) &_i 0)) end "failed, %s" 0 _s.dllerror

str s=F"\Harddisk{d.DeviceNumber}\partition{d.PartitionNumber}"
out s
#5
1. Works beautifully, thanks.

2. Most complicated, i don't know if I will use it.

For information, i suppose x: is the tested drive, and what does the
L"...." syntax do exactly (i use a lot F"...")
#6
I changed that part. Now can use drive letter variable.
#7
Hi Gintaras, hi all,

revive the thread cos I could use it in different way, but I need to tweak it.

Function ReparseTest
Trigger $f 0xBFF "T:\WatchedFolder"     Help - how to add the trigger to the macro
Code:
Copy      Help
function event $name [$newname]
;event: 1 added, 2 removed, 4 renamed, 8 modified
_s=name
sel event
,case [8]:
,int attr=GetFileAttributesW(@F"{name}"); if(attr=-1) end "failed, %s" 0 _s.dllerror
,if(attr&FILE_ATTRIBUTE_REPARSE_POINT) UseUSBDisk(_s)
,;else out F"{name} directory"

This code works flawlessly for months now, is used to mount USB disk to junction, and i'd like to extend it that way:

When a junction is created, a new *dynamic* file/folder trigger function is launched to monitor the newly created junction for monitoring file/folder changes
on the USB disk, and when junction is no more used (ie USB disk is disconnected), the new trigger function stops.

Possible?

Thanks.
#8
newitem - creates or deletes a macro. Can create with a trigger.
dis - disables or enables a macro.

See also ChangeFileTriggerFolder.
Folder modification trigger.


Forum Jump:


Users browsing this thread: 1 Guest(s)