C# Class mybox.Common

A class which is used to store common functions common to the client and server
Afficher le fichier Open project: jonocodes/mybox

Méthodes publiques

Свойство Type Description
TempDir String
UserHome String

Méthodes publiques

Méthode Description
BufferToSignal ( byte buffer ) : Signal

Convert a byte array to a single byte signal

CreateLocalDirectory ( String absPath ) : bool

Create a directory on the local filesystem if it does not exist

DateTimeToUnixTimestamp ( System.DateTime dateTime ) : long

Convert DateTime to unix timestamp.

DeleteLocal ( String absPath ) : bool

Delete a local file or directory

EncryptPassword ( string pwd, string salt ) : string

Enrcypt a password with a salt and return the result

EndDirWithSlash ( String absPath ) : string

Make sure the input directory path has a trailing slash.

ExitError ( ) : void

Quit the program when an error occurs.

FileChecksumToBytes ( String absPath ) : byte[]
FileChecksumToString ( String absPath ) : String
GenerateSalt ( int size ) : string

Generates a random salt for password encryption purposes

GetFilesRecursive ( string baseDir ) : List

Gets a recursive listing of files from a directory

GetModTime ( String fullPath ) : long

Get the data modification time of a local file

Md5Hash ( String input ) : String

Md5 digest a string.

ReceiveFile ( Socket socket, string baseDir ) : MyFile

Receive a file over a socket

ReceiveString ( Socket socket ) : String

Get a string from a socket which is sent by SendString

SendString ( Socket socket, String str ) : bool

Send a string along a socket

Sha256Hash ( String input ) : String

Compute Sha256 for a string.

ShowCliHelp ( OptionSet options, Assembly thisAssembly ) : void

Display the command line options and then exit.

SignalToBuffer ( Signal signal ) : byte[]

Convert the signal to a byte array

UnixTimeStampToDateTime ( long unixTimeStamp ) : System.DateTime

Convert UNIX timestamp to a datetime object

Private Methods

Méthode Description
SendFile ( String relPath, Socket socket, String baseDir ) : MyFile

Method Details

BufferToSignal() public static méthode

Convert a byte array to a single byte signal
public static BufferToSignal ( byte buffer ) : Signal
buffer byte
Résultat Signal

CreateLocalDirectory() public static méthode

Create a directory on the local filesystem if it does not exist
public static CreateLocalDirectory ( String absPath ) : bool
absPath String
Résultat bool

DateTimeToUnixTimestamp() public static méthode

Convert DateTime to unix timestamp.
public static DateTimeToUnixTimestamp ( System.DateTime dateTime ) : long
dateTime System.DateTime /// DateTime ///
Résultat long

DeleteLocal() public static méthode

Delete a local file or directory
public static DeleteLocal ( String absPath ) : bool
absPath String the absolute path to the item
Résultat bool

EncryptPassword() public static méthode

Enrcypt a password with a salt and return the result
public static EncryptPassword ( string pwd, string salt ) : string
pwd string
salt string
Résultat string

EndDirWithSlash() public static méthode

Make sure the input directory path has a trailing slash.
public static EndDirWithSlash ( String absPath ) : string
absPath String
Résultat string

ExitError() public static méthode

Quit the program when an error occurs.
public static ExitError ( ) : void
Résultat void

FileChecksumToBytes() public static méthode

public static FileChecksumToBytes ( String absPath ) : byte[]
absPath String
Résultat byte[]

FileChecksumToString() public static méthode

public static FileChecksumToString ( String absPath ) : String
absPath String
Résultat String

GenerateSalt() public static méthode

Generates a random salt for password encryption purposes
public static GenerateSalt ( int size ) : string
size int the length in bytes of the salt
Résultat string

GetFilesRecursive() public static méthode

Gets a recursive listing of files from a directory
public static GetFilesRecursive ( string baseDir ) : List
baseDir string
Résultat List

GetModTime() public static méthode

Get the data modification time of a local file
public static GetModTime ( String fullPath ) : long
fullPath String
Résultat long

Md5Hash() public static méthode

Md5 digest a string.
public static Md5Hash ( String input ) : String
input String /// Any string ///
Résultat String

ReceiveFile() public static méthode

Receive a file over a socket
public static ReceiveFile ( Socket socket, string baseDir ) : MyFile
socket System.Net.Sockets.Socket
baseDir string the base directory the file will live in
Résultat MyFile

ReceiveString() public static méthode

Get a string from a socket which is sent by SendString
public static ReceiveString ( Socket socket ) : String
socket System.Net.Sockets.Socket
Résultat String

SendString() public static méthode

Send a string along a socket
public static SendString ( Socket socket, String str ) : bool
socket System.Net.Sockets.Socket
str String
Résultat bool

Sha256Hash() public static méthode

Compute Sha256 for a string.
public static Sha256Hash ( String input ) : String
input String /// Input. ///
Résultat String

ShowCliHelp() public static méthode

Display the command line options and then exit.
public static ShowCliHelp ( OptionSet options, Assembly thisAssembly ) : void
options OptionSet
thisAssembly System.Reflection.Assembly
Résultat void

SignalToBuffer() public static méthode

Convert the signal to a byte array
public static SignalToBuffer ( Signal signal ) : byte[]
signal Signal
Résultat byte[]

UnixTimeStampToDateTime() public static méthode

Convert UNIX timestamp to a datetime object
public static UnixTimeStampToDateTime ( long unixTimeStamp ) : System.DateTime
unixTimeStamp long /// Unix time stamp. ///
Résultat System.DateTime

Property Details

TempDir public_oe static_oe property

The system temp directory
public static String TempDir
Résultat String

UserHome public_oe static_oe property

The user's system home directory primarialy used for determining where the config directory is
public static String UserHome
Résultat String