Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        private static bool Error(string error)
        {
            if (string.IsNullOrEmpty(error))
            {
                _errorBuffer[0] = 0;
                return(false);
            }

            CharsetConverter.UTF16ToUTF8Buffer(error, _errorBuffer, ErrorBufferSize);

            return(false);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }