Advertisement
Anders

FS; UpdateFileWriteTime

May 3rd, 2011
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Outfile "$%temp%\test.exe"
  2. requestexecutionlevel user
  3. showinstdetails show
  4. page instfiles
  5.  
  6. !include FileFunc.nsh
  7. !include LogicLib.nsh
  8.  
  9. section
  10. InitPluginsDir
  11. SetOutPath $pluginsdir
  12.  
  13.  
  14. FileOpen $0 "$pluginsdir\1.txt" w
  15. FileWrite $0 "Hello World"
  16. Push $0
  17.  
  18. FileOpen $0 "$pluginsdir\2.txt" w
  19. Push $0
  20.  
  21. FileOpen $0 "$pluginsdir\3.txt" w
  22. Push $0
  23.  
  24. FileOpen $0 "$pluginsdir\4.txt" w
  25. Push $0 #FileClose $0
  26.  
  27.  
  28.  
  29. Sleep 2000
  30.  
  31. FileOpen $0 "$pluginsdir\ref.txt" w
  32. FileClose $0
  33. ${GetTime} "$pluginsdir\ref.txt" M $0 $1 $2 $3 $4 $5 $6
  34. DetailPrint "Target: $4:$5:$6"
  35. DetailPrint " "
  36.  
  37.  
  38. #!define FILE_WRITE_ATTRIBUTES 0x0100
  39. Pop $0 #FileOpen $0 "$pluginsdir\4.txt" w
  40. System::Alloc 24
  41. System::Call 'kernel32::GetSystemTime(isr1)'
  42. IntOp $2 $1 + 16 ;Ptr to FILETIME
  43. System::Call 'kernel32::SystemTimeToFileTime(ir1,ir2)'
  44. System::Call 'kernel32::SetFileTime(ir0,i0,i0,ir2)'
  45. System::Free $1
  46. FileClose $0
  47. ${GetTime} "$pluginsdir\4.txt" M $0 $1 $2 $3 $4 $5 $6
  48. DetailPrint "SetFileTime: $4:$5:$6"
  49.  
  50.  
  51. pop $0
  52. System::Call 'kernel32::FlushFileBuffers(ir0)'
  53. FileClose $0
  54. ${GetTime} "$pluginsdir\3.txt" M $0 $1 $2 $3 $4 $5 $6
  55. DetailPrint "FlushFileBuffers: $4:$5:$6"
  56.  
  57.  
  58. pop $0
  59. FileClose $0
  60. ${GetTime} "$pluginsdir\2.txt" M $0 $1 $2 $3 $4 $5 $6
  61. DetailPrint "CloseHandle: $4:$5:$6"
  62.  
  63.  
  64. pop $0
  65. FileSeek $0 0 SET ; just to be safe
  66. FileReadByte $0 $1
  67. ${If} $1 != "" ;Not going to work if the file is empty
  68.     FileSeek $0 0 SET
  69.     FileWriteByte $0 $1
  70. ${EndIf}
  71. FileClose $0
  72. ${GetTime} "$pluginsdir\1.txt" M $0 $1 $2 $3 $4 $5 $6
  73. DetailPrint "FileReadByte+FileWriteByte: $4:$5:$6"
  74.  
  75.  
  76. SetDetailsPrint textonly
  77. SetOutPath $temp
  78. sectionend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement