英文:
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函数可以设置许多属性。
import "golang.org/x/sys/windows"
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论