# IRfFileSupport Interface Reference

Inherits IUnknown.

List of all members.

## Public Member Functions
HRESULT | EnumDirectoryContent ([in] BSTR szDirectoryPath,[in] BSTR szFilter,[out, retval] LPSAFEARRAY *ppFileInfoArray)
HRESULT | StartDirectoryChangesMonitor ([in] BSTR szDirectory,[out, retval] void **ppHandle)
HRESULT | ReadDirectoryChanges ([in] void *pHandle,[in] BYTE *pBuffer,[in] DWORD nBufferSize,[out, retval] DWORD *pBytesReturned)
HRESULT | StopDirectoryChangesMonitor ([in] void *pHandle)
HRESULT | CreateFile ([in] BSTR pszFilePath)
HRESULT | WriteFile ([in] BSTR pszFilePath,[in] BYTE *pBuffer,[in] DWORD nSize)
HRESULT | ReadFile ([in] BSTR pszFilePath,[in] BYTE *pBuffer,[in] DWORD nBufferSize)
HRESULT | FileExist ([in] BSTR szFilePath,[out, retval] BOOL *bExist)
HRESULT | GetUniqueFileName ([in] BSTR bszDirectory,[in] BSTR bszBaseName,[in] BSTR bszExt,[in] RtDWORD dwMaxAttempts,[out, retval] BSTR *pbszUniqueName)
HRESULT | GetFileInfo ([in] BSTR szFilePath,[out, retval] IRsFileInfo **ppFileInfo)
HRESULT | DeleteFile ([in] BSTR szFilePath,[in] BOOL bAllowUndo)
HRESULT | RenameFile ([in] BSTR szFilePath,[in] BSTR szNewFileName)
HRESULT | RenameDirectory ([in] BSTR szFilePath,[in] BSTR szNewFileName)
HRESULT | CopyFile ([in] BSTR bszSourceFilePath,[in] BSTR bszDestinationFilePath)
HRESULT | MoveFile ([in] BSTR bszSourceFilePath,[in] BSTR bszDestinationFilePath)
HRESULT | CreateDirectory ([in] BSTR szDirectoryPath)
HRESULT | DeleteDirectory ([in] BSTR szDirectoryPath,[in] BOOL bAllowUndo)
HRESULT | CreateDirectoryRecursive ([in] BSTR szDirectoryPath)

## Detailed Description

The file support function set wraps selected operation over the file system.

## Member Function Documentation

HRESULT IRfFileSupport::EnumDirectoryContent | ( | [in] BSTR | szDirectoryPath,
|  | [in] BSTR | szFilter,
|  | [out, retval] LPSAFEARRAY * | ppFileInfoArray |
| ) |  |  |

Enumerate directory content.

Parameters:

  | szFilter | [in] Specify the filter for the enumeration. You can use standard wildcard characters.

Returns:
  ppFileInfoArray [out, retval] Returns CComSafeArray<IUnknown *> of the enumerated items.
  - The array contains objects with IRsFileInfo interface.

  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::StartDirectoryChangesMonitor | ( | [in] BSTR | szDirectory,
|  | [out, retval] void ** | ppHandle |
| ) |  |  |

Use this method to attach to a directory events monitoring.

Parameters:

  | szDirectory | [in] Specify the directory which you want to monitor.

Returns:
  ppHandle [out, retval] Returns handle of the monitoring.
  - To stop the monitoring and release the handle call StopDirectoryChangesMonitor method.

  Standard HRESULT processing can be applied to the result.

Remarks:
  To read the events use ReadDirectoryChanges.
  - It is recommended you read the events in regular time through a timer or thread.

HRESULT IRfFileSupport::ReadDirectoryChanges | ( | [in] void * | pHandle,
|  | [in] BYTE * | pBuffer,
|  | [in] DWORD | nBufferSize,
|  | [out, retval] DWORD * | pBytesReturned |
| ) |  |  |

Call this method to read the events of the monitored directory.

- See StartDirectoryChangesMonitor for more information.

Parameters:

  | pHandle | [in] Directory monitor handle.
  | pBuffer | [in] Specify pointer to the buffer where the events will be copied. The buffer is filled by FILE_NOTIFY_INFORMATION structure.
  | nBufferSize | [in] Size of the buffer you specified.

Returns:
  pBytesReturned [out, retval] Returns real used bytes of the buffer you specified.
  - If the value is 0, the buffer size you specified is too small.

  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::StopDirectoryChangesMonitor | ( | [in] void * | pHandle | ) |

Stop the directory monitoring and release the monitor handle.

Parameters:

  | pHandle | [in] Handle of the directory monitor you received by StartDirectoryChangesMonitor calling.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::CreateFile | ( | [in] BSTR | pszFilePath | ) |

Call the method to ensure the file exist.

- If it doesn't exist, it will be created.

Parameters:

  | pszFilePath | [in] File path of the file you want to check/create.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::WriteFile | ( | [in] BSTR | pszFilePath,
|  | [in] BYTE * | pBuffer,
|  | [in] DWORD | nSize |
| ) |  |  |

Write buffer to specified file.

- If the file doesn't exist, it will be created.

Parameters:

  | pszFilePath | [in] Specify the file path to which you want write the buffer.
  | pBuffer | [in] Pointer to buffer you want to write.
  | nSize | [in] Size of the buffer.

Returns:
  S_OK if successfully written or E_FAIL if not.

HRESULT IRfFileSupport::ReadFile | ( | [in] BSTR | pszFilePath,
|  | [in] BYTE * | pBuffer,
|  | [in] DWORD | nBufferSize |
| ) |  |  |

Read buffer from specified file.

Parameters:

  | pszFilePath | [in] The file path from which you want read the buffer.
  | pBuffer | [in] Pointer of the buffer where the data will be read.
  | nBufferSize | [in] Size of the buffer.

Returns:
  S_OK if successfully read or E_FAIL if not.

HRESULT IRfFileSupport::FileExist | ( | [in] BSTR | szFilePath,
|  | [out, retval] BOOL * | bExist |
| ) |  |  |

Call to check if a file or directory exist.

Parameters:

  | szFilePath | [in] File path you want to check.

Returns:
  bExist [out, retval] Returns TRUE if the path exist or FALSE if it doesn't.
  - You can specify this parameter as NULL and read the result from return value.

  S_OK if the path exist or S_FALSE if it doesn't.

HRESULT IRfFileSupport::GetUniqueFileName | ( | [in] BSTR | bszDirectory,
|  | [in] BSTR | bszBaseName,
|  | [in] BSTR | bszExt,
|  | [in] RtDWORD | dwMaxAttempts,
|  | [out, retval] BSTR * | pbszUniqueName |
| ) |  |  |

Call to get unique name in a directory.

Parameters:

  | bszDirectory | [in] The directory in which you want get unique file name.
  | bszBaseName | [in] Base name of the file name.
  | bszExt | [in] Extension of the file name.
  | dwMaxAttempts | [in] Specify the maximum attempts to find unique name.

Returns:
  pbszUniqueName [out, retval] Returns unique name in the directory

  Standard HRESULT processing can be applied to the result.

Remarks:
  First the method check filename assembled as:
  - bszDirectory + bszBaseName + bszExt
    For other attempts the name will be assembled as:
  - bszDirectory + bszBaseName + ", <attempt number>" + bszExt

HRESULT IRfFileSupport::GetFileInfo | ( | [in] BSTR | szFilePath,
|  | [out, retval] IRsFileInfo ** | ppFileInfo |
| ) |  |  |

Call to get file information.

Parameters:

  | szFilePath | [in] File path of the file you want it's file information.

Returns:
  ppFileInfo [out, retval] Returns file information.
  - See IRsFileInfo.

  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::DeleteFile | ( | [in] BSTR | szFilePath,
|  | [in] BOOL | bAllowUndo |
| ) |  |  |

Remove specified file.

Parameters:

  | szFilePath | [in] File path you want to delete.
  | bAllowUndo | [in] If TRUE, the file will be moved to Recycle Bin. If FALSE, the file will be deleted.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::RenameFile | ( | [in] BSTR | szFilePath,
|  | [in] BSTR | szNewFileName |
| ) |  |  |

Rename specified file.

Parameters:

  | szFilePath | [in] File path you want to rename.
  | szNewFileName | [in] New file name of the file.

Returns:
  S_OK if the file was successfully renamed or E_FAIL if it isn't.

HRESULT IRfFileSupport::RenameDirectory | ( | [in] BSTR | szFilePath,
|  | [in] BSTR | szNewFileName |
| ) |  |  |

Rename specified directory.

Parameters:

  | szFilePath | [in] File path of the directory you want to rename.
  | szNewFileName | [in] New file name of the directory.

Returns:
  S_OK if the directory was successfully renamed or E_FAIL if it isn't.

HRESULT IRfFileSupport::CopyFile | ( | [in] BSTR | bszSourceFilePath,
|  | [in] BSTR | bszDestinationFilePath |
| ) |  |  |

Copy file.

Parameters:

  | bszSourceFilePath | [in] The source path of the file.
  | bszDestinationFilePath | [in] The destination path of the file.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRfFileSupport::MoveFile | ( | [in] BSTR | bszSourceFilePath,
|  | [in] BSTR | bszDestinationFilePath |
| ) |  |  |

Move file from source to destionation path.

Parameters:

  | bszSourceFilePath | [in] The source path of the file.
  | bszDestinationFilePath | [in] The destination path of the file.

Returns:
  S_OK if the file was successfully moved or E_FAIL if it wasn't.

HRESULT IRfFileSupport::CreateDirectory | ( | [in] BSTR | szDirectoryPath | ) |

Create specified directory.

Parameters:

  | szDirectoryPath | [in] Specify the directory path you want to create.

Returns:
  S_OK if the directory was successfully created or E_FAIL if it wasn't.

HRESULT IRfFileSupport::DeleteDirectory | ( | [in] BSTR | szDirectoryPath,
|  | [in] BOOL | bAllowUndo |
| ) |  |  |

Remove specified directory.

Parameters:

  | szDirectoryPath | [in] Specify the directory path you want to remove.
  | bAllowUndo | [in] If TRUE, the directory will be moved to Recycle Bin. If FALSE, the file will be deleted.

Returns:
  S_OK if the directory was successfully created or E_FAIL if it wasn't.

HRESULT IRfFileSupport::CreateDirectoryRecursive | ( | [in] BSTR | szDirectoryPath | ) |

Recursively creates directory with all subpaths specified.

- For example if you want to create directory C:, the routine creates Foo directory if it does not exist and also "Bar" directory inside "Foo".

Parameters:

  | szDirectoryPath | [in] Specify the directory path you want to create.

Returns:
  S_OK if the directory was successfully created or E_FAIL if it wasn't.