Adds a reparse rule.
int AddReparseRule(const char* lpszMask, const char* lpszReparseMask, const char* lpszProductGUID, int iFlags);
INT AddReparseRule(LPCWSTR lpszMask, LPCWSTR lpszReparseMask, LPCWSTR lpszProductGUID, INT iFlags);
This method adds a reparse rule for the files and directories that match the specified Mask. Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule replaces it.
If the rule is added successfully, this method returns true; otherwise, it returns false.
Reparse rules are used to redirect access from a file or directory covered by Mask to another location in the filesystem, specified by ReparseMask.
The Mask and ReparseMask parameters must be valid file masks according to the File Masks topic. Only the files and directories which match Mask will be covered by the rule (i.e., redirected to the path specified by ReparseMask). For example, passing *.txt for Mask and *_1.txt for ReparseMask would cause, e.g., test.txt to be redirected to test_1.txt.
More generally, for each wildcard (* or ?) present in Mask, there must be a corresponding wildcard (of the same type) in ReparseMask; and the wildcards in ReparseMask must appear in the same order as they do in Mask. For example, if Mask is 20??_Budget.*, then 20??_Budget_Report.* would be a legal value for ReparseMask; but 20??_Budget_Report.xls would not be, nor would 20*_Budget_Report.*.
The ProductGUID parameter identifies the application that the rule should be associated with in the registry. In most cases, the value passed for this parameter should be the same one that was used to call the Initialize method.
The Flags parameter specifies how, exactly, the redirection should be performed. Possible values are:
|FS_REPARSE_CHANGE_PATH||0||Perform redirection by modifying the path directly using the CBFilter system driver.|
|FS_REPARSE_USE_REPARSE_POINT||1||Perform redirection by having the CBFilter system driver emulate real reparse point behavior.
This option will cause the driver to report that a file or directory's parent directory is a reparse point of the SYMLINK variety. Redirection performed in this manner is more consistent with Windows' own behavior; however, some software may fail to correctly handle paths that cross such symbolic links.
Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (such as, e.g., during the AfterFilterAttachToVolume and AfterFilterDetachFromVolume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists occurs in a thread-safe manner.
Error Handling (C++)
This method returns a Boolean value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.