C# Class kOS.Safe.Persistence.PersistenceUtilities

Afficher le fichier Open project: KSP-KOS/KOS Class Usage Examples

Méthodes publiques

Свойство Type Description
GzipHeader byte[]

Méthodes publiques

Méthode Description
CharNeedsEncoding ( char character ) : bool

Returns true if the character has to be encoded and cannot be dumped into a persistence file as-is.

CookedFilename ( string fileName, string extensionName, bool trusted = false ) : string

This is both for error checking and blessing of user-created filenames, and to tack on a filename extension if there is none present.


Returns a version of the filename in which it has had the file extension added unless the filename already has any sort of file extension, in which case nothing is changed about it. If every place where the auto- extension-appending is attempted is done via this method, then it will never end up adding an extension when an explicit one exists already.

DecodeBase64ToBinary ( string input ) : byte[]
DecodeLine ( string input ) : string
EncodeBase64 ( byte input ) : string
EncodeLine ( string input ) : string
IdentifyCategory ( byte firstBytes ) : FileCategory

Given the first few bytes of content, decide what the FileCategory should be, based on what's in the Content.
This should be called before deciding how to set the content.

IsBinary ( FileCategory category ) : bool

Method Details

CharNeedsEncoding() public static méthode

Returns true if the character has to be encoded and cannot be dumped into a persistence file as-is.
public static CharNeedsEncoding ( char character ) : bool
character char character to test
Résultat bool

CookedFilename() public static méthode

This is both for error checking and blessing of user-created filenames, and to tack on a filename extension if there is none present.


Returns a version of the filename in which it has had the file extension added unless the filename already has any sort of file extension, in which case nothing is changed about it. If every place where the auto- extension-appending is attempted is done via this method, then it will never end up adding an extension when an explicit one exists already.
public static CookedFilename ( string fileName, string extensionName, bool trusted = false ) : string
fileName string Filename to maybe change. Can be full path or just the filename.
extensionName string Extension to add if there is none already.
trusted bool True if the filename is internally generated (and therefore allowed to /// have paths in it). False if the filename is from a user-land string (and therefore allowing /// a name that walks the directory tree is a security hole.)
Résultat string

DecodeBase64ToBinary() public static méthode

public static DecodeBase64ToBinary ( string input ) : byte[]
input string
Résultat byte[]

DecodeLine() public static méthode

public static DecodeLine ( string input ) : string
input string
Résultat string

EncodeBase64() public static méthode

public static EncodeBase64 ( byte input ) : string
input byte
Résultat string

EncodeLine() public static méthode

public static EncodeLine ( string input ) : string
input string
Résultat string

IdentifyCategory() public static méthode

Given the first few bytes of content, decide what the FileCategory should be, based on what's in the Content.
This should be called before deciding how to set the content.
public static IdentifyCategory ( byte firstBytes ) : FileCategory
firstBytes byte At least the first four bytes of the file read in binary form - can be longer if you wish
Résultat FileCategory

IsBinary() public static méthode

public static IsBinary ( FileCategory category ) : bool
category FileCategory
Résultat bool

Property Details

GzipHeader public_oe static_oe property

public static byte[] GzipHeader
Résultat byte[]