Пример #1
0
        public LocalFile Create(LocalDrive drive, FileSystemInfo file, bool isRoot)
        {
			Func<LocalDrive, FileSystemInfo, bool, LocalFile> creator;
			if (!creators.TryGetValue(Environment.OSVersion.Platform, out creator))
            {
                throw new PlatformNotSupportedException();
            }
            return creator(drive, file, isRoot);
        }
Пример #2
0
        public LocalFile Create(LocalDrive drive, FileSystemInfo file, bool isRoot)
        {
            Func <LocalDrive, FileSystemInfo, bool, LocalFile> creator;

            if (!creators.TryGetValue(Environment.OSVersion.Platform, out creator))
            {
                throw new PlatformNotSupportedException();
            }
            return(creator(drive, file, isRoot));
        }
Пример #3
0
 protected LocalFile(LocalDrive drive, string path)
     : base(drive)
 {
     if (System.IO.File.Exists(path))
     {
         this.file = new FileInfo(path);
     }
     else
     {
         this.file = new DirectoryInfo(path);
     }
 }
Пример #4
0
 protected LocalFile(LocalDrive drive, string path)
     : base(drive)
 {
     if (System.IO.File.Exists(path))
     {
         this.file = new FileInfo(path);
     }
     else
     {
         this.file = new DirectoryInfo(path);
     }
 }
Пример #5
0
 public NtfsLocalFile(LocalDrive drive, FileSystemInfo file)
     : base(drive, file)
 {
 }
Пример #6
0
 protected LocalFile(LocalDrive drive, FileSystemInfo file)
     : base(drive)
 {
     this.file = file;
 }
Пример #7
0
		public UnixLocalFile(LocalDrive drive, FileSystemInfo file)
			:base(drive, file)
		{
		}
Пример #8
0
        public async Task <Account> CreateAccountAsync(AccountInfo info)
        {
            var token   = new CancellationToken();
            var storage = new Glacier(info.StorageVault, info.StorageRootPath, info.StorageAccessKeyId, info.StorageSecretAccessKey, info.StorageRegionEndpoint);
            await storage.InitAsync(token);

            var account         = new Account(storage);
            var accountCredPath = "accounts/" + info.AccountName + "/drive-credentials/";

            foreach (var d in info.Drives)
            {
                switch (d.DriveType)
                {
                case DriveType.GoogleDrive:

                    var drive =
                        await
                        GoogleDrive.CreateInstance(account, d.DriveId,
                                                   GoogleClientSecrets.Load(new MemoryStream(Resources.client_secret)).Secrets,
                                                   d.DriveRootPath,
                                                   accountCredPath + d.DriveId,
                                                   token);

                    drive.ImageMaxSize = d.DriveImageMaxSize;
                    await drive.GetServiceAsync(token);

                    account.Drives.Add(drive);
                    break;

                case DriveType.LocalDrive:
                    var localDrive = new Local.LocalDrive(account, d.DriveId, d.DriveRootPath)
                    {
                        ImageMaxSize = d.DriveImageMaxSize
                    };
                    account.Drives.Add(localDrive);
                    break;

                default:
                    throw new NotSupportedException("Drive with this type is not supported");
                }
            }

            var accountInventoryPath = "accounts/" + info.AccountName + "/glacier-inventory.xml";

            using (var store = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null))
            {
                if (store.FileExists(accountInventoryPath))
                {
                    using (var input = store.OpenFile(accountInventoryPath, FileMode.Open))
                    {
                        var reader = new StreamReader(input);
                        var xml    = await reader.ReadToEndAsync();

                        var doc          = XDocument.Load(new XmlTextReader(new StringReader(xml)));
                        var glacierDrive = new GlacierPseudoDrive(account, "inventory", doc);
                        account.Drives.Add(glacierDrive);
                    }
                }
            }
            return(account);
        }
Пример #9
0
 protected LocalFile(LocalDrive drive, FileSystemInfo file)
     : base(drive)
 {
     this.file = file;
 }
Пример #10
0
        public async Task<Account> CreateAccountAsync(AccountInfo info)
        {
            var token = new CancellationToken();
            var storage = new Glacier(info.StorageVault, info.StorageRootPath, info.StorageAccessKeyId, info.StorageSecretAccessKey, info.StorageRegionEndpoint);
            await storage.InitAsync(token);
            var account = new Account(storage);
            var accountCredPath = "accounts/" + info.AccountName + "/drive-credentials/";

            foreach (var d in info.Drives)
            {
                switch (d.DriveType)
                {
                    case DriveType.GoogleDrive:

                        var drive =
                            await
                                GoogleDrive.CreateInstance(account, d.DriveId,
                                    GoogleClientSecrets.Load(new MemoryStream(Resources.client_secret)).Secrets,
                                    d.DriveRootPath,
                                    accountCredPath + d.DriveId,
                                    token);

                        drive.ImageMaxSize = d.DriveImageMaxSize;
                        await drive.GetServiceAsync(token);
                        account.Drives.Add(drive);
                        break;
                    case DriveType.LocalDrive:
                        var localDrive = new Local.LocalDrive(account, d.DriveId, d.DriveRootPath)
                        {
                            ImageMaxSize = d.DriveImageMaxSize
                        };
                        account.Drives.Add(localDrive);
                        break;
                    default:
                        throw new NotSupportedException("Drive with this type is not supported");
                }
            }

            var accountInventoryPath = "accounts/" + info.AccountName + "/glacier-inventory.xml";
            using (var store = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null))
            {
                if (store.FileExists(accountInventoryPath))
                {
                    using (var input = store.OpenFile(accountInventoryPath, FileMode.Open))
                    {
                        var reader = new StreamReader(input);
                        var xml = await reader.ReadToEndAsync();
                        var doc = XDocument.Load(new XmlTextReader(new StringReader(xml)));
                        var glacierDrive = new GlacierPseudoDrive(account, "inventory", doc);
                        account.Drives.Add(glacierDrive);
                    }
                }
            }
            return account;
        }