Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between FILE_ATTRIBUTE_NORMAL and 0?

What is the difference between passing the FILE_ATTRIBUTE_NORMAL (0x80) and 0 to CreateFile function?

like image 232
Ivan Ivanov Avatar asked Sep 20 '14 09:09

Ivan Ivanov


People also ask

What does CreateFile do?

The CreateFile function can create a new file or open an existing file. You must specify the file name, creation instructions, and other attributes. When an application creates a new file, the operating system adds it to the specified directory.

What are the Windows file attributes?

File attributes are pieces of information associated with every file and directory that includes additional data about the file itself or its contents. They can exist in only one of two states – Set or Cleared; like an On or Off state. Attributes can be in files, directories, volumes and certain system objects.

Where are file attributes stored?

File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via various file I/O APIs.

Is not a file attribute?

Which one of the following is not attributes of file? Explanation: rename is not the attribute of file rest all are files attributes.


2 Answers

From the MSDN page for CreateFile():

Note When CreateFile opens an existing file, it generally combines the file flags with the file attributes of the existing file, and ignores any file attributes supplied as part of dwFlagsAndAttributes.

Or to put it another way, you want a value that means "I don't care" when you open an existing file. Because the operating system doesn't care. That value is 0.

like image 87
Hans Passant Avatar answered Oct 29 '22 19:10

Hans Passant


FILE_ATTRIBUTE_NORMAL explicitly sets no attributes. If you pass 0, the set of attributes is unspecified.

like image 1
MSalters Avatar answered Oct 29 '22 19:10

MSalters