Ejemplo n.º 1
0
    private static async Task <byte[]> ReadBytesAsync(string path)
    {
        byte[] result;
        if (path == null)
        {
            result = null;
        }
        else
        {
            path = StorageUtility.ConvertPathSeparators(path);
            StorageFile storageFile = await StorageFile.GetFileFromPathAsync(path);

            StorageFile storageFile2 = storageFile;
            IBuffer     buffer       = await FileIO.ReadBufferAsync(storageFile2);

            DataReader var_10 = DataReader.FromBuffer(buffer);
            try
            {
                byte[] var_11_128 = new byte[var_10.get_UnconsumedBufferLength()];
                var_10.ReadBytes(var_11_128);
                result = var_11_128;
            }
            finally
            {
                int num;
                if (num < 0 && var_10 != null)
                {
                    var_10.Dispose();
                }
            }
        }
        return(result);
    }
Ejemplo n.º 2
0
    public static void FileWriteText(string path, string text)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <bool> task = StorageUtility.AsyncFileWriteText(path, text);

        task.Wait();
    }
Ejemplo n.º 3
0
    public static StorageFile GetFile(string path, FileOperationMode mode)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        StorageFile storageFile;

        try
        {
            storageFile = StorageUtility.GetFileFromPath(path);
        }
        catch (Exception ex)
        {
            if (mode == FileOperationMode.Append || mode == FileOperationMode.Create)
            {
                return(StorageUtility.CreateFile(path));
            }
            throw ex;
        }
        if (mode == FileOperationMode.Create)
        {
            StorageFile storageFile2 = StorageUtility.CreateFileAtPath(StorageUtility.ConvertPathSeparators(Application.temporaryCachePath), "temp", 0);
            StorageUtility.MoveAndReplaceFile(storageFile2, storageFile);
            storageFile = storageFile2;
        }
        return(storageFile);
    }
Ejemplo n.º 4
0
    public static void FileWriteLines(string path, string[] contents)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <bool> task = StorageUtility.AsyncFileWriteLines(path, contents);

        task.Wait();
    }
Ejemplo n.º 5
0
    public static void FileDelete(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <bool> task = StorageUtility.FileDeleteAsync(path);

        task.Wait();
    }
Ejemplo n.º 6
0
    public static StorageFolder GetFolderFromPath(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <StorageFolder> task = StorageUtility.AsyncGetFolderFromPath(path);

        task.Wait();
        return(task.Result);
    }
Ejemplo n.º 7
0
    public static string[] FileReadLines(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <IEnumerable <string> > task = StorageUtility.AsyncFileReadLines(path);

        task.Wait();
        return(task.Result.Cast <string>().ToArray <string>());
    }
Ejemplo n.º 8
0
    public static IBuffer FileReadBuffer(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        Task <IBuffer> task = StorageUtility.AsyncFileReadBuffer(path);

        task.Wait();
        return(task.Result);
    }
Ejemplo n.º 9
0
    public static void FileRename(string sourcePath, string destPath)
    {
        sourcePath = StorageUtility.ConvertPathSeparators(sourcePath);
        destPath   = StorageUtility.ConvertPathSeparators(destPath);
        Task <bool> task = StorageUtility.FileRenameAsync(sourcePath, destPath);

        task.Wait();
    }
Ejemplo n.º 10
0
    private static async Task <string> AsyncReadTextAsync(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        StorageFile storageFile = await StorageFile.GetFileFromPathAsync(path);

        StorageFile storageFile2 = storageFile;

        return(await FileIO.ReadTextAsync(storageFile2));
    }
Ejemplo n.º 11
0
    public static bool FolderExists(string path)
    {
        if (path == null)
        {
            return(false);
        }
        path = StorageUtility.ConvertPathSeparators(path);
        Task <bool> task = StorageUtility.FolderExistsAsync(path);

        task.Wait();
        return(task.Result);
    }
Ejemplo n.º 12
0
    public static StorageFile CreateFile(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        int pathSeparatorIndex = StorageUtility.GetPathSeparatorIndex(path, false);

        if (pathSeparatorIndex == -1)
        {
            throw new Exception("No folder in file path: " + path);
        }
        int           num           = pathSeparatorIndex + 1;
        StorageFolder storageFolder = null;
        string        text          = path;
        List <string> list          = new List <string>();

        while (storageFolder == null && pathSeparatorIndex != -1)
        {
            text = text.Substring(0, pathSeparatorIndex);
            pathSeparatorIndex = StorageUtility.GetPathSeparatorIndex(text, false);
            try
            {
                storageFolder = StorageUtility.GetFolderFromPath(text);
            }
            catch (Exception var_6_55)
            {
                if (pathSeparatorIndex != -1)
                {
                    list.Add(text.Substring(pathSeparatorIndex + 1));
                }
                storageFolder = null;
            }
        }
        if (storageFolder == null)
        {
            throw new Exception("No accesible folder found in path: " + path);
        }
        int count = list.Count;

        if (list.Count > 0)
        {
            for (int i = list.Count; i >= 0; i--)
            {
                storageFolder = StorageUtility.CreateFolder(storageFolder, list[i]);
            }
        }
        return(StorageUtility.CreateFile(storageFolder, path.Substring(num)));
    }
Ejemplo n.º 13
0
    public static string CreateFolderAtPath(string path)
    {
        path = StorageUtility.ConvertPathSeparators(path);
        while (StorageUtility.IsPathSeparator(path.get_Chars(path.get_Length() - 1)))
        {
            path = path.Substring(0, path.get_Length() - 1);
        }
        int           num           = path.get_Length();
        string        text          = path;
        List <string> list          = new List <string>();
        StorageFolder storageFolder = null;

        while (storageFolder == null && num != -1)
        {
            text = text.Substring(0, num);
            num  = StorageUtility.GetPathSeparatorIndex(text, false);
            try
            {
                storageFolder = StorageUtility.GetFolderFromPath(text);
            }
            catch (Exception var_4_5D)
            {
                if (num != -1)
                {
                    list.Add(text.Substring(num + 1));
                }
                storageFolder = null;
            }
        }
        if (storageFolder == null)
        {
            throw new Exception("No accesible folder found in path: " + path);
        }
        int count = list.Count;

        if (list.Count > 0)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                storageFolder = StorageUtility.CreateFolder(storageFolder, list[i]);
            }
        }
        return(storageFolder.get_Path());
    }
Ejemplo n.º 14
0
    private static async Task <bool> WriteBytesAsync(string path, byte[] buffer)
    {
        bool result;

        if (path == null)
        {
            result = false;
        }
        else
        {
            path = StorageUtility.ConvertPathSeparators(path);
            int         num         = path.LastIndexOf('\\');
            StorageFile storageFile = StorageUtility.CreateFileAtPath(path.Substring(0, num), path.Substring(num + 1), 3);
            await FileIO.WriteBytesAsync(storageFile, buffer);

            result = true;
        }
        return(result);
    }
Ejemplo n.º 15
0
 public unsafe static long $Invoke13(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(StorageUtility.ConvertPathSeparators(Marshal.PtrToStringUni(*(IntPtr *)args))));
 }
Ejemplo n.º 16
0
 public static void FileCopy(string sourcePath, string destPath)
 {
     sourcePath = StorageUtility.ConvertPathSeparators(sourcePath);
     destPath   = StorageUtility.ConvertPathSeparators(destPath);
     StorageUtility.FileCopy(sourcePath, destPath, false);
 }