Example #1
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);
    }
Example #2
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)));
    }
Example #3
0
 public unsafe static long $Invoke16(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(StorageUtility.CreateFile((StorageFolder)GCHandledObjects.GCHandleToObject(*args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)), *(int *)(args + 2))));
 }
Example #4
0
 public unsafe static long $Invoke14(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(StorageUtility.CreateFile(Marshal.PtrToStringUni(*(IntPtr *)args))));
 }
Example #5
0
 public static StorageFile CreateFile(StorageFolder folder, string name)
 {
     return(StorageUtility.CreateFile(folder, name, 1));
 }