Mkdirs() public method

public Mkdirs ( ) : bool
return bool
Esempio n. 1
0
 public BlobStore(string path)
 {
     this.path = path;
     FilePath directory = new FilePath(path);
     directory.Mkdirs();
     if (!directory.IsDirectory()) {
         throw new InvalidOperationException(string.Format("Unable to create directory for: {0}", directory));
     }
 }
Esempio n. 2
0
		/// <exception cref="System.IO.IOException"></exception>
		private void CreateDir(FilePath f)
		{
			if (!f.IsDirectory() && !f.Mkdirs())
			{
				FilePath p = f;
				while (p != null && !p.Exists())
				{
					p = p.GetParentFile();
				}
				if (p == null || p.IsDirectory())
				{
					throw new IOException(JGitText.Get().cannotCreateDirectory);
				}
				FileUtils.Delete(p);
				if (!f.Mkdirs())
				{
					throw new IOException(JGitText.Get().cannotCreateDirectory);
				}
			}
		}
Esempio n. 3
0
 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 private void ReplaceDatabase(string databaseName, InputStream databaseStream, IEnumerator
     <KeyValuePair<string, InputStream>> attachmentStreams)
 {
     try
     {
         Database database = GetDatabase(databaseName);
         string dstAttachmentsPath = database.GetAttachmentStorePath();
         OutputStream destStream = new FileOutputStream(new FilePath(database.GetPath()));
         StreamUtils.CopyStream(databaseStream, destStream);
         FilePath attachmentsFile = new FilePath(dstAttachmentsPath);
         FileDirUtils.DeleteRecursive(attachmentsFile);
         attachmentsFile.Mkdirs();
         if (attachmentStreams != null)
         {
             StreamUtils.CopyStreamsToFolder(attachmentStreams, attachmentsFile);
         }
         database.Open();
         database.ReplaceUUIDs();
     }
     catch (FileNotFoundException e)
     {
         Log.E(Database.Tag, string.Empty, e);
         throw new CouchbaseLiteException(Status.InternalServerError);
     }
     catch (IOException e)
     {
         Log.E(Database.Tag, string.Empty, e);
         throw new CouchbaseLiteException(Status.InternalServerError);
     }
 }
Esempio n. 4
0
 public Manager(Context context, ManagerOptions options)
 {
     Log.I(Database.Tag, "Starting Manager version: %s", Couchbase.Lite.Manager.Version
         );
     this.context = context;
     this.directoryFile = context.GetFilesDir();
     this.options = (options != null) ? options : DefaultOptions;
     this.databases = new Dictionary<string, Database>();
     this.replications = new AList<Replication>();
     directoryFile.Mkdirs();
     if (!directoryFile.IsDirectory())
     {
         throw new IOException(string.Format("Unable to create directory for: %s", directoryFile
             ));
     }
     UpgradeOldDatabaseFiles(directoryFile);
     workExecutor = Executors.NewSingleThreadScheduledExecutor();
 }
Esempio n. 5
0
		private FilePath GetOutputFile(FilePath parentDir, string className)
		{
			string path = className.Replace('.', FilePath.separatorChar);
			path = System.String.Concat(path, ".class");
			FilePath f = new FilePath(parentDir, path);
			string dirPath = f.GetParent();
			if (dirPath != null)
			{
				FilePath dir = new FilePath(dirPath);
				if (!dir.Exists())
				{
					dir.Mkdirs();
				}
			}
			return f;
		}
 public FileInfo TempDir()
 {
     FilePath directory = new FilePath(path);
     FilePath tempDirectory = new FilePath(directory, "temp_attachments");
     tempDirectory.Mkdirs();
     if (!tempDirectory.IsDirectory())
     {
         throw new InvalidOperationException(string.Format("Unable to create directory for: {0}"
             , tempDirectory));
     }
     return tempDirectory;
 }
Esempio n. 7
0
 public virtual void ReplaceDatabase(string databaseName, FilePath databaseFile, FilePath
      attachmentsDirectory)
 {
     Database database = GetDatabase(databaseName);
     string dstAttachmentsPath = database.GetAttachmentStorePath();
     FilePath destFile = new FilePath(database.GetPath());
     FileDirUtils.CopyFile(databaseFile, destFile);
     FilePath attachmentsFile = new FilePath(dstAttachmentsPath);
     FileDirUtils.DeleteRecursive(attachmentsFile);
     attachmentsFile.Mkdirs();
     if (attachmentsDirectory != null)
     {
         FileDirUtils.CopyFolder(attachmentsDirectory, attachmentsFile);
     }
     database.ReplaceUUIDs();
 }
Esempio n. 8
0
 public Manager(FilePath directoryFile, ManagerOptions options)
 {
     this.directoryFile = directoryFile;
     this.options = (options != null) ? options : DefaultOptions;
     this.databases = new Dictionary<string, Database>();
     this.replications = new AList<Replication>();
     directoryFile.Mkdirs();
     if (!directoryFile.IsDirectory())
     {
         throw new IOException(string.Format("Unable to create directory for: %s", directoryFile
             ));
     }
     UpgradeOldDatabaseFiles(directoryFile);
     workExecutor = Executors.NewSingleThreadScheduledExecutor();
 }
Esempio n. 9
0
		public void ReplaceDatabase(string databaseName, FilePath databaseFile, FilePath 
			attachmentsDirectory)
		{
			try
			{
				Database database = GetDatabase(databaseName);
				string dstAttachmentsPath = database.GetAttachmentStorePath();
				FilePath destFile = new FilePath(database.GetPath());
				FileDirUtils.CopyFile(databaseFile, destFile);
				FilePath attachmentsFile = new FilePath(dstAttachmentsPath);
				FileDirUtils.DeleteRecursive(attachmentsFile);
				attachmentsFile.Mkdirs();
				if (attachmentsDirectory != null)
				{
					FileDirUtils.CopyFolder(attachmentsDirectory, attachmentsFile);
				}
				database.ReplaceUUIDs();
			}
			catch (IOException e)
			{
				Log.E(Database.Tag, string.Empty, e);
				throw new CouchbaseLiteException(Status.InternalServerError);
			}
		}
Esempio n. 10
0
 /// <summary>
 /// Creates the directory named by this abstract pathname, including any
 /// necessary but nonexistent parent directories.
 /// </summary>
 /// <remarks>
 /// Creates the directory named by this abstract pathname, including any
 /// necessary but nonexistent parent directories. Note that if this operation
 /// fails it may have succeeded in creating some of the necessary parent
 /// directories.
 /// </remarks>
 /// <param name="d">directory to be created</param>
 /// <param name="skipExisting">
 /// if
 /// <code>true</code>
 /// skip creation of the given directory if it
 /// already exists in the file system
 /// </param>
 /// <exception cref="System.IO.IOException">
 /// if creation of
 /// <code>d</code>
 /// fails. This may occur if
 /// <code>d</code>
 /// did exist when the method was called. This can therefore
 /// cause IOExceptions during race conditions when multiple
 /// concurrent threads all try to create the same directory.
 /// </exception>
 public static void Mkdirs(FilePath d, bool skipExisting)
 {
     if (!d.Mkdirs())
     {
         if (skipExisting && d.IsDirectory())
         {
             return;
         }
         throw new IOException(MessageFormat.Format(JGitText.Get().mkDirsFailed, d.GetAbsolutePath
             ()));
     }
 }
        public BlobStore(string path, SymmetricKey encryptionKey)
        {
            if (path == null) {
                throw new ArgumentNullException("path");
            }

            _path = path;
            EncryptionKey = encryptionKey;
            FilePath directory = new FilePath(path);
            if (directory.Exists() && directory.IsDirectory()) {
                // Existing blob-store.
                VerifyExistingStore();
            } else {
                // New blob store; create directory:
                directory.Mkdirs();
                if (!directory.IsDirectory()) {
                    throw new InvalidOperationException(string.Format("Unable to create directory for: {0}", directory));
                }

                if (encryptionKey != null) {
                    MarkEncrypted(true);
                }
            }
        }
Esempio n. 12
0
		public override void Add(HostKey hostkey, UserInfo userinfo)
		{
			int type = hostkey.type;
			string host = hostkey.GetHost();
			byte[] key = hostkey.key;
			HostKey hk = null;
			lock (pool)
			{
				for (int i = 0; i < pool.Count; i++)
				{
					hk = (HostKey)(pool[i]);
					if (hk.IsMatched(host) && hk.type == type)
					{
					}
				}
			}
			hk = hostkey;
			pool.Add(hk);
			string bar = GetKnownHostsRepositoryID();
			if (bar != null)
			{
				bool foo = true;
				FilePath goo = new FilePath(bar);
				if (!goo.Exists())
				{
					foo = false;
					if (userinfo != null)
					{
						foo = userinfo.PromptYesNo(bar + " does not exist.\n" + "Are you sure you want to create it?"
							);
						goo = goo.GetParentFile();
						if (foo && goo != null && !goo.Exists())
						{
							foo = userinfo.PromptYesNo("The parent directory " + goo + " does not exist.\n" +
								 "Are you sure you want to create it?");
							if (foo)
							{
								if (!goo.Mkdirs())
								{
									userinfo.ShowMessage(goo + " has not been created.");
									foo = false;
								}
								else
								{
									userinfo.ShowMessage(goo + " has been succesfully created.\nPlease check its access permission."
										);
								}
							}
						}
						if (goo == null)
						{
							foo = false;
						}
					}
				}
				if (foo)
				{
					try
					{
						Sync(bar);
					}
					catch (Exception e)
					{
						System.Console.Error.WriteLine("sync known_hosts: " + e);
					}
				}
			}
		}