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 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);
        }