private static bool TryGetExistingFilePath(byte *pathPtr, out string outPath) { try { var length = CharsetConverter.UTF8Length(pathPtr); if (length == 0) { Error("Path is null or empty"); } outPath = CharsetConverter.UTF8BufferToString(pathPtr, length); if (string.IsNullOrWhiteSpace(outPath)) { return(Error("Path is empty")); } if (!File.Exists(outPath)) { return(Error($"File doesn't exist: '{outPath}'")); } return(true); } catch (Exception exception) { outPath = null; return(HandleException(exception)); } }
private static bool Error(string error) { if (string.IsNullOrEmpty(error)) { _errorBuffer[0] = 0; return(false); } CharsetConverter.UTF16ToUTF8Buffer(error, _errorBuffer, ErrorBufferSize); return(false); }
public static void Log(string text, LogLevel level) { if (string.IsNullOrEmpty(text)) { _logBuffer[0] = 0; LogInternal(level); return; } CharsetConverter.UTF16ToUTF8Buffer(text, _logBuffer, LogBufferSize); LogInternal(level); }
private static bool ValidFilePath(byte *pathPointer, out string outPath) { var length = CharsetConverter.UTF8Length(pathPointer); if (length == 0) { Error("Path is null or empty"); } outPath = CharsetConverter.UTF8BufferToString(pathPointer, length); if (string.IsNullOrWhiteSpace(outPath)) { return(Error("Path is empty")); } return(true); }