Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Config        cfg        = new Config();
            var           liveClient = Login(cfg);
            CryptoManager cryptoMgr;

            if (cfg.Get("expanded-password", null) == null)
            {
                var password = cfg.Get("password", null);
                if (password == null)
                {
                    Console.WriteLine("passwordを指定してね");
                    return;
                }
                var salt = cfg.Get("password-salt", "encrypted-userspace-overlay-filesystem-over-cloud-storage");
                cryptoMgr = new CryptoManager(password, salt);
                cfg.Set("expanded-password", Convert.ToBase64String(cryptoMgr.Key));
                cfg.Delete("password");
                cfg.Save();
            }
            else
            {
                cryptoMgr = new CryptoManager(Convert.FromBase64String(cfg.Get("expanded-password", null)));
            }
            using (var baseFS = new OneDrive.FileSystem(cfg, liveClient))
                using (FileSystem fs = new FileSystem(cfg, baseFS, cryptoMgr)) {
                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        // Mono-FUSE
                        using (Fuse fuse = new Fuse(fs)) {
                            args            = fuse.ParseFuseArguments(args);
                            fuse.MountPoint = "/mnt/fuse";
                            fuse.Start();
                        }
                    }
                    else
                    {
                        // Dokan.NET (TODO)
                    }
                }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string confDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EncryptedOneDrive");

            if (!Directory.Exists(confDir))
            {
                Directory.CreateDirectory(confDir);
            }

            string tokenFile = Path.Combine(confDir, "token.txt");

            if (!File.Exists(tokenFile))
            {
                throw new FileNotFoundException(tokenFile);
            }
            string token;

            using (StreamReader reader = new StreamReader(tokenFile)) {
                token = reader.ReadLine().Trim();
            }

            OneDriveClient oneDriveClient = new OneDriveClient(token);
            CryptoManager  cryptoMgr      = new CryptoManager("password", "encrypted-userspace-filesystem-over-onedrive");

            using (FileSystem fs = new FileSystem(oneDriveClient, cryptoMgr)) {
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    // Mono-FUSE
                    using (Fuse fuse = new Fuse(fs)) {
                        args            = fuse.ParseFuseArguments(args);
                        fuse.MountPoint = "/mnt/fuse";
                        fuse.Start();
                    }
                }
                else
                {
                    // Dokan.NET (TODO)
                }
            }
        }