Joutsen v0.5.0+12-g5dd5f7e
Public Member Functions | List of all members
Joutsen.IO.Filesystem Interface Reference

An interface offering methods to interact with the filesystem. More...

Public Member Functions

File GetFile (string path)
 Fetches a file from the filesystem. More...
 
File GetFile (FilesystemPath path)
 Fetches a file from the filesystem. More...
 
File CreateFile (string path, global::System.IO.Stream content=null)
 Creates a new file with content. More...
 
File CreateFile (FilesystemPath path, global::System.IO.Stream content=null)
 Creates a new file with content. More...
 
File CopyFile (string sourcePath, string destinationPath, bool overwrite=false)
 Copies a file from sourcePath to destinationPath. More...
 
File CopyFile (FilesystemPath sourcePath, FilesystemPath destinationPath, bool overwrite=false)
 Copies a file from sourcePath to destinationPath. More...
 
File MoveFile (string sourcePath, string destinationPath)
 Moves a file to a different location. More...
 
File MoveFile (FilesystemPath sourcePath, FilesystemPath destinationPath)
 Moves a file to a different location. More...
 
void DeleteFile (string path)
 Deletes the file on from the filesystem. More...
 
void DeleteFile (FilesystemPath path)
 Deletes the file on from the filesystem. More...
 
File ReplaceFile (string sourcePath, string destinationPath, string backupPath)
 Replaces the file at destinationPath with the file at sourcePath creating a backup in backupPath. More...
 
File ReplaceFile (FilesystemPath sourcePath, FilesystemPath destinationPath, FilesystemPath backupPath)
 Replaces the file at destinationPath with the file at sourcePath creating a backup in backupPath. More...
 
bool FileExists (string path)
 Checks if a file exists in the filesystem. More...
 
Folder GetFolder (string path)
 Fetches a folder from the filesystem. More...
 
Folder GetFolder (FilesystemPath path)
 Fetches a folder from the filesystem. More...
 
Folder CreateFolder (string path)
 Creates a new folder. More...
 
Folder CreateFolder (FilesystemPath path)
 Creates a new folder. More...
 
Folder CopyFolder (string sourcePath, string destinationPath, bool recursive, bool overwrite=false)
 Copies a folder from sourcePath to destinationPath. More...
 
Folder CopyFolder (FilesystemPath sourcePath, FilesystemPath destinationPath, bool recursive, bool overwrite=false)
 Copies a folder from sourcePath to destinationPath. More...
 
Folder MoveFolder (string sourcePath, string destinationPath, bool keepFolder=false)
 Moves a folder to a different location. More...
 
Folder MoveFolder (FilesystemPath sourcePath, FilesystemPath destinationPath, bool keepFolder=false)
 Moves a folder to a different location. More...
 
void DeleteFolder (string path, bool recursive=false)
 Deletes a folder from the filesystem. More...
 
void DeleteFolder (FilesystemPath path, bool recursive=false)
 Deletes a folder from the filesystem. More...
 
Set< FilesystemPathListFolder (string path, string searchPattern="*")
 Lists the content a the folder. More...
 
Set< FilesystemPathListFolder (FilesystemPath path, string searchPattern="*")
 Lists the content a the folder. More...
 
SCG.IEnumerable< FilesystemPathWalkFolder (string path, string searchPattern="*")
 Walks the filesystem returning one file or folder contained in this folder at a time. More...
 
SCG.IEnumerable< FilesystemPathWalkFolder (FilesystemPath path, string searchPattern="*")
 Walks the filesystem returning one file or folder contained in this folder at a time. More...
 
bool FolderExists (string path)
 Checks if a folder exists in the filesystem. More...
 
void CreatePath (string path)
 Creates an entire path by creating all the folders belonging to it. More...
 
void CreatePath (FilesystemPath path)
 Creates an entire path by creating all the folders belonging to it. More...
 
bool PathExists (string path)
 Checks if the path exists on the filesystem. More...
 

Detailed Description

An interface offering methods to interact with the filesystem.

Since
0.4.0

Member Function Documentation

◆ CopyFile() [1/2]

File Joutsen.IO.Filesystem.CopyFile ( FilesystemPath  sourcePath,
FilesystemPath  destinationPath,
bool  overwrite = false 
)

Copies a file from sourcePath to destinationPath.

Parameters
sourcePaththe path to copy the file from
destinationPaththe path to copy the file to
overwritedetermines if an existing file at destinationPath should be overwritten
Returns
the file representing the copy

Implemented in Joutsen.IO.LocalFilesystem.

◆ CopyFile() [2/2]

File Joutsen.IO.Filesystem.CopyFile ( string  sourcePath,
string  destinationPath,
bool  overwrite = false 
)

Copies a file from sourcePath to destinationPath.

Parameters
sourcePaththe path to copy the file from
destinationPaththe path to copy the file to
overwritedetermines if an existing file at destinationPath should be overwritten
Returns
the file representing the copy

Implemented in Joutsen.IO.LocalFilesystem.

◆ CopyFolder() [1/2]

Folder Joutsen.IO.Filesystem.CopyFolder ( FilesystemPath  sourcePath,
FilesystemPath  destinationPath,
bool  recursive,
bool  overwrite = false 
)

Copies a folder from sourcePath to destinationPath.

Parameters
sourcePaththe path to copy the folder from
destinationPaththe path to copy the folder to
recursivedetermines if subfolders should be copied as well
overwritedetermines if an existing folder at destinationPath should be replaced
Returns
the folder representing the copy
Remarks
Copying a folder is not an atomic operation. Therefore it is likely that parts of the folder are already copied if an error occurs during the copy process. These parts are not cleaned up.

Implemented in Joutsen.IO.LocalFilesystem.

◆ CopyFolder() [2/2]

Folder Joutsen.IO.Filesystem.CopyFolder ( string  sourcePath,
string  destinationPath,
bool  recursive,
bool  overwrite = false 
)

Copies a folder from sourcePath to destinationPath.

Parameters
sourcePaththe path to copy the folder from
destinationPaththe path to copy the folder to
recursivedetermines if subfolders should be copied as well
overwritedetermines if an existing folder at destinationPath should be replaced
Returns
the folder representing the copy
Remarks
Copying a folder is not an atomic operation. Therefore it is likely that parts of the folder are already copied if an error occurs during the copy process. These parts are not cleaned up.

Implemented in Joutsen.IO.LocalFilesystem.

◆ CreateFile() [1/2]

File Joutsen.IO.Filesystem.CreateFile ( FilesystemPath  path,
global::System.IO.Stream  content = null 
)

Creates a new file with content.

Parameters
paththe path to the new file
contentoptional, the content that should be written to the new file. If content is null, an empty file is created.

◆ CreateFile() [2/2]

File Joutsen.IO.Filesystem.CreateFile ( string  path,
global::System.IO.Stream  content = null 
)

Creates a new file with content.

Parameters
paththe path to the new file
contentoptional, the content that should be written to the new file. If content is null, an empty file is created.

◆ CreateFolder() [1/2]

Folder Joutsen.IO.Filesystem.CreateFolder ( FilesystemPath  path)

Creates a new folder.

Parameters
paththe path to the new folder

Implemented in Joutsen.IO.LocalFilesystem.

◆ CreateFolder() [2/2]

Folder Joutsen.IO.Filesystem.CreateFolder ( string  path)

Creates a new folder.

Parameters
paththe path to the new folder

Implemented in Joutsen.IO.LocalFilesystem.

◆ CreatePath() [1/2]

void Joutsen.IO.Filesystem.CreatePath ( FilesystemPath  path)

Creates an entire path by creating all the folders belonging to it.

Parameters
thepath to create
Remarks
This method creates only folders and should therefore not be used with file paths.

Implemented in Joutsen.IO.LocalFilesystem.

◆ CreatePath() [2/2]

void Joutsen.IO.Filesystem.CreatePath ( string  path)

Creates an entire path by creating all the folders belonging to it.

Parameters
thepath to create
Remarks
This method creates only folders and should therefore not be used with file paths.

Implemented in Joutsen.IO.LocalFilesystem.

◆ DeleteFile() [1/2]

void Joutsen.IO.Filesystem.DeleteFile ( FilesystemPath  path)

Deletes the file on from the filesystem.

Parameters
paththe path to the file to delete

Implemented in Joutsen.IO.LocalFilesystem.

◆ DeleteFile() [2/2]

void Joutsen.IO.Filesystem.DeleteFile ( string  path)

Deletes the file on from the filesystem.

Parameters
paththe path to the file to delete

Implemented in Joutsen.IO.LocalFilesystem.

◆ DeleteFolder() [1/2]

void Joutsen.IO.Filesystem.DeleteFolder ( FilesystemPath  path,
bool  recursive = false 
)

Deletes a folder from the filesystem.

Parameters
paththe path to the folder to delete
recursivedetermines if the folder should only be deleted if it is empty or if files and subfolders should be deleted as well

Implemented in Joutsen.IO.LocalFilesystem.

◆ DeleteFolder() [2/2]

void Joutsen.IO.Filesystem.DeleteFolder ( string  path,
bool  recursive = false 
)

Deletes a folder from the filesystem.

Parameters
paththe path to the folder to delete
recursivedetermines if the folder should only be deleted if it is empty or if files and subfolders should be deleted as well

Implemented in Joutsen.IO.LocalFilesystem.

◆ FileExists()

bool Joutsen.IO.Filesystem.FileExists ( string  path)

Checks if a file exists in the filesystem.

Parameters
thepath to the file

Implemented in Joutsen.IO.LocalFilesystem.

◆ FolderExists()

bool Joutsen.IO.Filesystem.FolderExists ( string  path)

Checks if a folder exists in the filesystem.

Parameters
thepath to the folder

Implemented in Joutsen.IO.LocalFilesystem.

◆ GetFile() [1/2]

File Joutsen.IO.Filesystem.GetFile ( FilesystemPath  path)

Fetches a file from the filesystem.

Parameters
thepath to the file
Returns
the file that can be found at path on the filesystem.

Implemented in Joutsen.IO.LocalFilesystem.

◆ GetFile() [2/2]

File Joutsen.IO.Filesystem.GetFile ( string  path)

Fetches a file from the filesystem.

Parameters
thepath to the file
Returns
the file that can be found at path on the filesystem.

Implemented in Joutsen.IO.LocalFilesystem.

◆ GetFolder() [1/2]

Folder Joutsen.IO.Filesystem.GetFolder ( FilesystemPath  path)

Fetches a folder from the filesystem.

Parameters
thepath to the folder
Returns
the folder that can be found at path on the filesystem.

Implemented in Joutsen.IO.LocalFilesystem.

◆ GetFolder() [2/2]

Folder Joutsen.IO.Filesystem.GetFolder ( string  path)

Fetches a folder from the filesystem.

Parameters
thepath to the folder
Returns
the folder that can be found at path on the filesystem.

Implemented in Joutsen.IO.LocalFilesystem.

◆ ListFolder() [1/2]

Set< FilesystemPath > Joutsen.IO.Filesystem.ListFolder ( FilesystemPath  path,
string  searchPattern = "*" 
)

Lists the content a the folder.

Parameters
thepath to the folder
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in the folder sorted by their names

Implemented in Joutsen.IO.LocalFilesystem.

◆ ListFolder() [2/2]

Set< FilesystemPath > Joutsen.IO.Filesystem.ListFolder ( string  path,
string  searchPattern = "*" 
)

Lists the content a the folder.

Parameters
thepath to the folder
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in the folder sorted by their names

Implemented in Joutsen.IO.LocalFilesystem.

◆ MoveFile() [1/2]

File Joutsen.IO.Filesystem.MoveFile ( FilesystemPath  sourcePath,
FilesystemPath  destinationPath 
)

Moves a file to a different location.

Parameters
sourcePaththe path to move te file from
destinationPaththe path to move the file to
Returns
the file representing the moved file

Implemented in Joutsen.IO.LocalFilesystem.

◆ MoveFile() [2/2]

File Joutsen.IO.Filesystem.MoveFile ( string  sourcePath,
string  destinationPath 
)

Moves a file to a different location.

Parameters
sourcePaththe path to move te file from
destinationPaththe path to move the file to
Returns
the file representing the moved file

Implemented in Joutsen.IO.LocalFilesystem.

◆ MoveFolder() [1/2]

Folder Joutsen.IO.Filesystem.MoveFolder ( FilesystemPath  sourcePath,
FilesystemPath  destinationPath,
bool  keepFolder = false 
)

Moves a folder to a different location.

Parameters
sourcePaththe path to move te folder from
destinationPaththe path to move the folder to
keepFolderif keepFolder is false the content of the folder will be moved to the new location. If it is false the folder is moved into the folder defined by dstPath
Returns
the Folder representing the moved folder

Implemented in Joutsen.IO.LocalFilesystem.

◆ MoveFolder() [2/2]

Folder Joutsen.IO.Filesystem.MoveFolder ( string  sourcePath,
string  destinationPath,
bool  keepFolder = false 
)

Moves a folder to a different location.

Parameters
sourcePaththe path to move te folder from
destinationPaththe path to move the folder to
keepFolderif keepFolder is false the content of the folder will be moved to the new location. If it is false the folder is moved into the folder defined by dstPath
Returns
the Folder representing the moved folder

Implemented in Joutsen.IO.LocalFilesystem.

◆ PathExists()

bool Joutsen.IO.Filesystem.PathExists ( string  path)

Checks if the path exists on the filesystem.

Parameters
paththe path to check
Returns
true if the path leads to a valid object on the filesystem, otherwise false

Implemented in Joutsen.IO.LocalFilesystem.

◆ ReplaceFile() [1/2]

File Joutsen.IO.Filesystem.ReplaceFile ( FilesystemPath  sourcePath,
FilesystemPath  destinationPath,
FilesystemPath  backupPath 
)

Replaces the file at destinationPath with the file at sourcePath creating a backup in backupPath.

Parameters
sourcePaththe path to the source file
destinationPaththe path to the file that should be replaced
backupPaththe path to the location where the backup of the file at dstPath should be stored
Returns
a file representing the backup of the replaced file or null if no backup is created
Remarks
If null is passed as backupPath, no backup is created. The original file is deleted by this method.

Implemented in Joutsen.IO.LocalFilesystem.

◆ ReplaceFile() [2/2]

File Joutsen.IO.Filesystem.ReplaceFile ( string  sourcePath,
string  destinationPath,
string  backupPath 
)

Replaces the file at destinationPath with the file at sourcePath creating a backup in backupPath.

Parameters
sourcePaththe path to the source file
destinationPaththe path to the file that should be replaced
backupPaththe path to the location where the backup of the file at dstPath should be stored
Returns
a file representing the backup of the replaced file or null if no backup is created
Remarks
If null is passed as backupPath, no backup is created. The original file is deleted by this method.

Implemented in Joutsen.IO.LocalFilesystem.

◆ WalkFolder() [1/2]

SCG.IEnumerable< FilesystemPath > Joutsen.IO.Filesystem.WalkFolder ( FilesystemPath  path,
string  searchPattern = "*" 
)

Walks the filesystem returning one file or folder contained in this folder at a time.

Parameters
paththe path to the folder
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in the folder one at a time

Implemented in Joutsen.IO.LocalFilesystem.

◆ WalkFolder() [2/2]

SCG.IEnumerable< FilesystemPath > Joutsen.IO.Filesystem.WalkFolder ( string  path,
string  searchPattern = "*" 
)

Walks the filesystem returning one file or folder contained in this folder at a time.

Parameters
paththe path to the folder
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in the folder one at a time

Implemented in Joutsen.IO.LocalFilesystem.