本文整理汇总了C#中FileAttributes.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# FileAttributes.HasFlag方法的具体用法?C# FileAttributes.HasFlag怎么用?C# FileAttributes.HasFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileAttributes
的用法示例。
在下文中一共展示了FileAttributes.HasFlag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFolder
public override void CreateFolder(string folder, FileAttributes attributes) {
folder = folder.Replace('\\', '/');
PutObjectRequest request = new PutObjectRequest() {
BucketName = this.bucket,
Key = this.prefix + folder + '/',
ContentBody = "",
StorageClass = this.storageClass,
};
this.withHandling(() => {
request.AddHeader("x-amz-meta-hidden", attributes.HasFlag(FileAttributes.Hidden) ? "true" : "false");
request.AddHeader("x-amz-meta-archive", attributes.HasFlag(FileAttributes.Archive) ? "true" : "false");
request.AddHeader("x-amz-meta-not-index", attributes.HasFlag(FileAttributes.NotContentIndexed) ? "true" : "false");
this.client.PutObject(request);
}, folder);
this.folders.Add(folder);
}
示例2: AttributeBreakdown
public static AttributeFlags AttributeBreakdown(FileAttributes flags)
{
AttributeFlags attributes = new AttributeFlags();
if (flags.HasFlag(FileAttributes.Normal))
attributes.Normal = true;
if (flags.HasFlag(FileAttributes.Archive))
attributes.Archive = true;
if (flags.HasFlag(FileAttributes.Compressed))
attributes.Compressed = true;
if (flags.HasFlag(FileAttributes.Device))
attributes.Device = true;
if (flags.HasFlag(FileAttributes.Directory))
attributes.Directory = true;
if (flags.HasFlag(FileAttributes.Encrypted))
attributes.Encrypted = true;
if (flags.HasFlag(FileAttributes.Hidden))
attributes.Hidden = true;
if (flags.HasFlag(FileAttributes.IntegrityStream))
attributes.IntegrityStream = true;
if (flags.HasFlag(FileAttributes.NoScrubData))
attributes.NoScrubData = true;
if (flags.HasFlag(FileAttributes.NotContentIndexed))
attributes.NotContentIndexed = true;
if (flags.HasFlag(FileAttributes.Offline))
attributes.Offline = true;
if (flags.HasFlag(FileAttributes.ReadOnly))
attributes.ReadOnly = true;
if (flags.HasFlag(FileAttributes.ReparsePoint))
attributes.ReparsePoint = true;
if (flags.HasFlag(FileAttributes.SparseFile))
attributes.SparseFile = true;
if (flags.HasFlag(FileAttributes.System))
attributes.System = true;
if (flags.HasFlag(FileAttributes.Temporary))
attributes.Temporary = true;
return attributes;
}
示例3: GetMode
private static string GetMode(FileAttributes attr)
{
var sb = new StringBuilder();
sb.Append(attr.HasFlag(FileAttributes.Directory) ? "d" : "-");
sb.Append(attr.HasFlag(FileAttributes.Archive) ? "a" : "-");
sb.Append(attr.HasFlag(FileAttributes.ReadOnly) ? "r" : "-");
sb.Append(attr.HasFlag(FileAttributes.Hidden) ? "h" : "-");
sb.Append(attr.HasFlag(FileAttributes.System) ? "s" : "-");
sb.Append(attr.HasFlag(FileAttributes.ReparsePoint) ? "l" : "-");
return sb.ToString();
}
示例4: LogFSActionError
DokanError IDokanOperations.SetFileAttributes(string fileName, FileAttributes attributes, DokanFileInfo info)
{
LogFSActionError("SetFileAttr", fileName, (SftpContext)info.Context, "Attrs:{0}", attributes);
//get actual attributes
string path = GetUnixPath(fileName);
SftpFileAttributes currentattr = GetAttributes(path);
//rules for changes:
bool rightsupdate = false;
if (attributes.HasFlag(FileAttributes.Archive) && !GroupRightsSameAsOwner(currentattr))
{
LogFSActionSuccess("SetFileAttr", fileName, (SftpContext)info.Context, "Setting group rights to owner");
//Archive goes ON, rights of group same as owner:
currentattr.GroupCanWrite = currentattr.OwnerCanWrite;
currentattr.GroupCanExecute = currentattr.OwnerCanExecute;
currentattr.GroupCanRead = currentattr.OwnerCanRead;
rightsupdate = true;
}
if (!attributes.HasFlag(FileAttributes.Archive) && GroupRightsSameAsOwner(currentattr))
{
LogFSActionSuccess("SetFileAttr", fileName, (SftpContext)info.Context, "Setting group rights to others");
//Archive goes OFF, rights of group same as others:
currentattr.GroupCanWrite = currentattr.OthersCanWrite;
currentattr.GroupCanExecute = currentattr.OthersCanExecute;
currentattr.GroupCanRead = currentattr.OthersCanRead;
rightsupdate = true;
}
//apply new settings:
if (rightsupdate)
{
//apply and reset cache
try
{
_sftpSession.RequestSetStat(GetUnixPath(fileName), currentattr);
}
catch(SftpPermissionDeniedException e)
{
return DokanError.ErrorAccessDenied;
}
CacheReset(path);
CacheResetParent(path); //parent cache need reset also
//if context exists, update new rights manually is needed
SftpContext context = (SftpContext)info.Context;
if (info.Context != null)
{
context.Attributes.GroupCanWrite = currentattr.GroupCanWrite;
context.Attributes.GroupCanExecute = currentattr.GroupCanExecute;
context.Attributes.GroupCanRead = currentattr.GroupCanRead;
}
}
return DokanError.ErrorSuccess;
}
示例5: IsDirectoryAllowed
public bool IsDirectoryAllowed(string relativePath, FileAttributes attributes) {
return !attributes.HasFlag(FileAttributes.Hidden);
}
示例6: IsFileAllowed
public bool IsFileAllowed(string relativePath, FileAttributes attributes) {
return !attributes.HasFlag(FileAttributes.Hidden)
&& !HasExtension(relativePath, ".user", RContentTypeDefinition.VsRProjectExtension, ".sln");
}
示例7: IsSymbolicLink
public bool IsSymbolicLink( FileAttributes fileAttributes )
{
var isError = (int)fileAttributes == -1;
var isSymbolicLink = fileAttributes.HasFlag( FileAttributes.ReparsePoint );
return !isError && isSymbolicLink;
}
示例8: CreateFile
public override bool CreateFile(string file, string source, DateTime lastModified, string fileMD5, FileAttributes attributes, bool reportProgress=true) {
file = file.Replace('\\', '/');
string key = this.prefix + file;
if (this.files.Contains(file) && this.FileMD5(file) == fileMD5) {
return false;
}
PutObjectRequest putRequest = new PutObjectRequest() {
BucketName = this.bucket,
FilePath = source,
Key = key,
Timeout = -1,
CannedACL = S3CannedACL.Private,
StorageClass = this.storageClass,
};
if (reportProgress)
putRequest.PutObjectProgressEvent += new EventHandler<PutObjectProgressArgs>(putRequest_PutObjectProgressEvent);
this.withHandling(() => {
putRequest.AddHeader("x-amz-meta-md5", fileMD5);
putRequest.AddHeader("x-amz-meta-hidden", attributes.HasFlag(FileAttributes.Hidden) ? "true" : "false");
putRequest.AddHeader("x-amz-meta-archive", attributes.HasFlag(FileAttributes.Archive) ? "true" : "false");
putRequest.AddHeader("x-amz-meta-not-index", attributes.HasFlag(FileAttributes.NotContentIndexed) ? "true" : "false");
this.client.PutObject(putRequest);
}, file);
this.files.Add(file);
return true;
}
示例9: IsFileAllowed
public bool IsFileAllowed(string relativePath, FileAttributes attributes) {
return !attributes.HasFlag(FileAttributes.Hidden)
&& !HasExtension(relativePath, ".user", ".rxproj", ".sln");
}