Thread: question about CreateFile and FILE_FLAG_WRITE_THROUGH

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    question about CreateFile and FILE_FLAG_WRITE_THROUGH

    Hello everyone,


    Suppose I have a file created with FILE_ATTRIBUTE_NORMAL attribute. I think it means attribute FILE_FLAG_WRITE_THROUGH is not enabled. Is my understanding correct?

    And I think if I do not enable the FILE_FLAG_WRITE_THROUGH attribute, even if flush operation (function call) will not *truly* dump data to disk. Is my understanding also correct?

    So, my question is, when will the data be dumped to disk -- only when we close the file?


    thanks in advance,
    George

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by George2
    Hello everyone,


    Suppose I have a file created with FILE_ATTRIBUTE_NORMAL attribute. I think it means attribute FILE_FLAG_WRITE_THROUGH is not enabled. Is my understanding correct?
    Correct.

    And I think if I do not enable the FILE_FLAG_WRITE_THROUGH attribute, even if flush operation (function call) will not *truly* dump data to disk. Is my understanding also correct?
    The flush operation should ensure that everything goes to disk. Why would you suspect otherwise?

    Why would you want to use that flag anyway?

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    Quote Originally Posted by iMalc
    Correct.The flush operation should ensure that everything goes to disk. Why would you suspect otherwise?

    Why would you want to use that flag anyway?
    Do you mean even if I only invoke write API (without flush) when in FILE_FLAG_WRITE_THROUGH mode, the OS buffer and the physical content on disk are the same?

    Another question is, if FILE_FLAG_WRITE_THROUGH mode is not enabled, how will data lose? (I think if FILE_FLAG_WRITE_THROUGH is not enabled, we could invoke flush, and whether or not FILE_FLAG_WRITE_THROUGH is enebled, flush will definitely write OS buffer data to external disk. Is my understanding correct?)


    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateFile() and CONOUT$
    By cboard_member in forum Windows Programming
    Replies: 1
    Last Post: 06-30-2006, 02:30 PM
  2. CreateFile() giving errors
    By neandrake in forum Windows Programming
    Replies: 2
    Last Post: 09-27-2004, 10:29 PM
  3. Serial comm W32 using CreateFile
    By Foldager in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2003, 01:13 PM
  4. fopen and CreateFile
    By Bajanine in forum Windows Programming
    Replies: 3
    Last Post: 04-03-2003, 07:24 PM
  5. CreateFile and Long Path/Files :: Win32
    By kuphryn in forum Windows Programming
    Replies: 4
    Last Post: 12-27-2002, 10:26 PM