本文整理汇总了C#中Sharpen.FilePath.Mkdirs方法的典型用法代码示例。如果您正苦于以下问题:C# FilePath.Mkdirs方法的具体用法?C# FilePath.Mkdirs怎么用?C# FilePath.Mkdirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sharpen.FilePath
的用法示例。
在下文中一共展示了FilePath.Mkdirs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlobStore
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));
}
}
示例2: CreateDir
/// <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);
}
}
}
示例3: ReplaceDatabase
/// <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);
}
}
示例4: Manager
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();
}
示例5: GetOutputFile
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;
}
示例6: TempDir
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;
}
示例7: ReplaceDatabase
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();
}
示例8: Manager
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();
}
示例9: ReplaceDatabase
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);
}
}
示例10: Mkdirs
/// <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
()));
}
}
示例11: BlobStore
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);
}
}
}
示例12: Add
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);
}
}
}
}