C# Class NanoByte.Common.Native.UnixUtils

Provides helper methods for Unix-specific features of the Mono library.
This class has a dependency on Mono.Posix. Make sure to check IsUnix before calling any other methods in this class to avoid missing assembly exceptions.
Show file Open project: nano-byte/common

Private Properties

Property Type Description
AreHardlinked bool
CreateHardlink void
CreateSymlink void
GetFileSystem string
GetXattr byte[]
Rename void
SetXattr void

Public Methods

Method Description
IsExecutable ( [ path ) : bool

Checks whether a file is marked as Unix-executable.

Will return false for non-existing files.

IsRegularFile ( [ path ) : bool

Checks whether a file is a regular file (i.e. not a device file, symbolic link, etc.).

Will return false for non-existing files.

IsSymlink ( [ path ) : bool

Checks whether a file is a Unix symbolic link.

Will return false for non-existing files.

IsSymlink ( [ path, string &target ) : bool

Checks whether a file is a Unix symbolic link.

MakeReadOnly ( [ path ) : void

Removes write permissions for everyone on a filesystem object (file or directory).

MakeWritable ( [ path ) : void

Sets write permissions for the owner on a filesystem object (file or directory).

SetExecutable ( [ path, bool executable ) : void

Marks a file as Unix-executable or not Unix-executable.

Private Methods

Method Description
AreHardlinked ( [ path1, [ path2 ) : bool
CreateHardlink ( [ sourcePath, [ targetPath ) : void
CreateSymlink ( [ sourcePath, [ targetPath ) : void
GetFileSystem ( [ path ) : string
GetXattr ( [ path, [ name ) : byte[]
Rename ( [ source, [ destination ) : void
SetXattr ( [ path, [ name, [ data ) : void

Method Details

IsExecutable() public static method

Checks whether a file is marked as Unix-executable.
Will return false for non-existing files.
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static IsExecutable ( [ path ) : bool
path [ The file to check for executable rights.
return bool

IsRegularFile() public static method

Checks whether a file is a regular file (i.e. not a device file, symbolic link, etc.).
Will return false for non-existing files.
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static IsRegularFile ( [ path ) : bool
path [
return bool

IsSymlink() public static method

Checks whether a file is a Unix symbolic link.
Will return false for non-existing files.
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static IsSymlink ( [ path ) : bool
path [ The path of the file to check.
return bool

IsSymlink() public static method

Checks whether a file is a Unix symbolic link.
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static IsSymlink ( [ path, string &target ) : bool
path [ The path of the file to check.
target string Returns the target the symbolic link points to if it exists.
return bool

MakeReadOnly() public static method

Removes write permissions for everyone on a filesystem object (file or directory).
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static MakeReadOnly ( [ path ) : void
path [ The filesystem object (file or directory) to make read-only.
return void

MakeWritable() public static method

Sets write permissions for the owner on a filesystem object (file or directory).
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static MakeWritable ( [ path ) : void
path [ The filesystem object (file or directory) to make writeable by the owner.
return void

SetExecutable() public static method

Marks a file as Unix-executable or not Unix-executable.
The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights). The underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
public static SetExecutable ( [ path, bool executable ) : void
path [ The file to mark as executable or not executable.
executable bool true to mark the file as executable, true to mark it as not executable.
return void