如何使用Go语言翻转Windows文件的存档位?

huangapple go评论74阅读模式
英文:

How to flip the Windows archive bit for a file using Go

问题

我正在使用Go处理一系列文件,并希望通过文件元数据指示文件是否已被处理。如果文件至少被处理过一次,但在一个小时内未被程序处理,我希望将其删除。

我认为Windows的存档位可以很好地确定文件是否至少被处理过一次,因为这些文件是临时文件,不会被备份,从而防止意外翻转Windows的存档位。

英文:

I am processing a series of files using Go and I would like to indicate if a file has been processed using file metadata. If the file has been processed at least once but hasn't been processed by the program for an hour I would like to delete it.

I thought the Windows archive bit would be a good way of determining if the file has been processed at least once since these files are temporary and will not be backed up preventing accidental flipping of the Windows archive bit.

答案1

得分: 2

使用Microsoft Windows API:


检索和更改文件属性

应用程序可以使用GetFileAttributes或GetFileAttributesEx函数检索文件属性。CreateFile和SetFileAttributes函数可以设置许多属性。


package windows

import "golang.org/x/sys/windows"

func GetFileAttributes

func GetFileAttributesEx

func SetFileAttributes

英文:

Use the Microsoft Windows API:


> Retrieving and Changing File Attributes
>
> An application can retrieve the file attributes by using the
> GetFileAttributes or GetFileAttributesEx function. The CreateFile and
> SetFileAttributes functions can set many of the attributes.


> package windows
>
> import "golang.org/x/sys/windows"
>
> func GetFileAttributes
>
> func GetFileAttributesEx
>
> func SetFileAttributes

huangapple
  • 本文由 发表于 2017年7月7日 21:37:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/44972209.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定