本文整理汇总了C#中DokanNet.DokanFileInfo类的典型用法代码示例。如果您正苦于以下问题:C# DokanFileInfo类的具体用法?C# DokanFileInfo怎么用?C# DokanFileInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DokanFileInfo类属于DokanNet命名空间,在下文中一共展示了DokanFileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDirectory
public DokanError CreateDirectory(string fileName, DokanFileInfo info)
{
//Console.WriteLine("CreateDirectory: {0}", fileName);
if (fileName == "\\")
{
return DokanError.ErrorSuccess;
}
if (fileName.EndsWith("\\"))
{
fileName = fileName.Substring(0, fileName.Length - 1);
}
Directory dir = new Directory(Util.GetPathDirectory(fileName));
if (!dir.Exists())
{
return DokanError.ErrorPathNotFound;
}
String name = Util.GetPathFileName(fileName);
if (dir.Contains(name))
{
return DokanError.ErrorAlreadyExists;
}
dir.CreateDirectory(name);
return DokanError.ErrorSuccess;
}
示例2: Cleanup
public void Cleanup(string fileName, DokanFileInfo info)
{
#if TRACE
if (info.Context != null)
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}('{1}', {2} - entering",
"Cleanup", fileName, ToTrace(info)));
#endif
if (info.Context != null && info.Context is FileStream)
{
(info.Context as FileStream).Dispose();
}
info.Context = null;
if (info.DeleteOnClose)
{
if (info.IsDirectory)
{
Directory.Delete(GetPath(fileName));
}
else
{
File.Delete(GetPath(fileName));
}
}
Trace("Cleanup", fileName, info, DokanResult.Success);
}
示例3: CloseFile
public DokanError CloseFile(string fileName, DokanFileInfo info)
{
//Console.WriteLine("CloseFile: {0}", fileName);
// 可能打开文件时有 deleteOnClose 标记(Windows 8+)
if (info.Context != null)
{
File f = (File)info.Context;
if (f.flagDeleteOnClose)
{
Directory dir = new Directory(Util.GetPathDirectory(f.path));
if (!dir.Exists())
{
return DokanError.ErrorSuccess;
}
String name = Util.GetPathFileName(f.path);
if (!dir.Contains(name))
{
return DokanError.ErrorSuccess;
}
dir.Delete(name);
}
}
return DokanError.ErrorSuccess;
}
示例4: ToTrace
private string ToTrace(DokanFileInfo info)
{
var context = info.Context != null ? "<" + info.Context.GetType().Name + ">" : "<null>";
return string.Format(CultureInfo.InvariantCulture, "{{{0}, {1}, {2}, {3}, {4}, #{5}, {6}, {7}}}",
context, info.DeleteOnClose, info.IsDirectory, info.NoCache, info.PagingIo, info.ProcessId, info.SynchronousIo, info.WriteToEndOfFile);
}
示例5: CreateFile
public DokanError CreateFile(string fileName, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info)
{
info.DeleteOnClose = (options & FileOptions.DeleteOnClose) != 0;
//Console.WriteLine("CreateFile: {0}, mode = {1}", fileName, mode);
if (fileName == "\\")
{
return DokanError.ErrorSuccess;
}
Directory dir = new Directory(Util.GetPathDirectory(fileName));
if (!dir.Exists())
{
return DokanError.ErrorPathNotFound;
}
String name = Util.GetPathFileName(fileName);
if (name.Length == 0)
{
return DokanError.ErrorInvalidName;
}
if (name.IndexOfAny(Path.GetInvalidFileNameChars()) > -1)
{
return DokanError.ErrorInvalidName;
}
// dokan API 要求在目标文件是目录时候,设置 info.IsDirectory = true
if (dir.Contains(name) && (dir.GetItemInfo(name).attribute & FileAttributes.Directory) != 0)
{
info.IsDirectory = true;
return DokanError.ErrorSuccess;
}
try
{
File f = new File(fileName, mode);
f.flagDeleteOnClose = info.DeleteOnClose;
info.Context = f;
}
catch (FileNotFoundException)
{
return DokanError.ErrorFileNotFound;
}
catch (IOException)
{
return DokanError.ErrorAlreadyExists;
}
catch (NotImplementedException)
{
return DokanError.ErrorAccessDenied;
}
catch (Exception)
{
return DokanError.ErrorError;
}
return DokanError.ErrorSuccess;
}
示例6: FindFiles
public NtStatus FindFiles(string fileName, out IList<FileInformation> files, DokanFileInfo info)
{
//Console.Error.WriteLine("Attempted to findfiles for {0}", fileName);
//files = filesIndex.Select(fi => fi.FileInformation).ToList();
//files.Add(new FileInformation() { Attributes = FileAttributes.Directory, FileName = "\\" });
files = new List<FileInformation>();
return NtStatus.Success;
}
示例7: GetSubSystemOperations
DokanError IDokanOperations.CreateDirectory(string fileName, DokanFileInfo info)
{
SftpDrive drive = this.GetDriveByMountPoint(fileName, out fileName);
if (drive != null)
return GetSubSystemOperations(drive).CreateDirectory(fileName, info);
return DokanError.ErrorAccessDenied;
}
示例8: CloseFile
public void CloseFile(string fileName, DokanFileInfo info)
{
if (info.Context != null && info.Context is Stream)
{
(info.Context as Stream).Dispose();
}
info.Context = null;
}
示例9: CloseFile
public DokanError CloseFile(string fileName, DokanFileInfo info)
{
if (info.Context != null && info.Context is FileStream)
{
(info.Context as FileStream).Dispose();
}
info.Context = null;
return DokanError.ErrorSuccess; // could recreate cleanup code hear but this is not called sometimes
}
示例10: CreateFile
public DokanError CreateFile(
string filename,
FileAccess access,
System.IO.FileShare share,
System.IO.FileMode mode,
System.IO.FileOptions options,
System.IO.FileAttributes attributes,
DokanFileInfo info)
{
return DokanError.ErrorSuccess;
}
示例11: Trace
private NtStatus Trace(string method, string fileName, DokanFileInfo info,
FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes,
NtStatus result)
{
#if TRACE
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0}('{1}', {2}, [{3}], [{4}], [{5}], [{6}], [{7}]) -> {8}",
method, fileName, ToTrace(info), access, share, mode, options, attributes, result));
#endif
return result;
}
示例12: CreateFile
public NtStatus CreateFile(
string filename,
FileAccess access,
System.IO.FileShare share,
System.IO.FileMode mode,
System.IO.FileOptions options,
System.IO.FileAttributes attributes,
DokanFileInfo info)
{
return DokanResult.Success;
}
示例13: Trace
private NtStatus Trace(string method, string fileName, DokanFileInfo info,
FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes,
NtStatus result)
{
#if TRACE
logger.Debug(
DokanFormat(
$"{method}('{fileName}', {info}, [{access}], [{share}], [{mode}], [{options}], [{attributes}]) -> {result}"));
#endif
return result;
}
示例14: Cleanup
public void Cleanup(string fileName, DokanFileInfo info)
{
if (info.Context != null && info.Context is Stream)
{
(info.Context as Stream).Dispose();
}
info.Context = null;
if (info.DeleteOnClose)
{
// do nothig
}
}
示例15: CreateFile
public NtStatus CreateFile(
string filename,
FileAccess access,
System.IO.FileShare share,
System.IO.FileMode mode,
System.IO.FileOptions options,
System.IO.FileAttributes attributes,
DokanFileInfo info)
{
if (info.IsDirectory && mode == System.IO.FileMode.CreateNew)
return DokanResult.AccessDenied;
return DokanResult.Success;
}