フィルターのクリア

Modifying a memory-mapped data file

5 ビュー (過去 30 日間)
Ken
Ken 2018 年 1 月 6 日
コメント済み: Walter Roberson 2024 年 3 月 1 日
I am using memmapfile to managed and update structured data records. After I modify a record in the file, the "modified date" of the file is not updated. I do confirm that the record has been modified. Unfortunately, it seems that the memory-mapped file is not updated by by cloud service, presumably because the file "modified date" is not changed.
Does anyone know how this might be fixed/managed?

回答 (2 件)

Ben Drebing
Ben Drebing 2018 年 1 月 12 日
Unfortunately, this is a current limitation of MATLAB. But a quick way to get around this is to open and close it again after you've modify the file so that the modified time stamp gets updated. You can just do something like:
fileID = fopen('MyFile.dat','w');
fclose(fileID);
This will update the date modified without actually changing the file.
  8 件のコメント
Eivind Hennestad
Eivind Hennestad 2024 年 3 月 1 日
Also, for the record and to repeat what is noted in the discussion here, the first solution proposed by Ben is not correct. The following statement will wipe out the contents of the file:
fileID = fopen('MyFile.dat','w');
Walter Roberson
Walter Roberson 2024 年 3 月 1 日
Ah, if the process is to open a file, read the first byte, rewind, and write back the first byte, then you should open with 'r+' permissions.
Opening with 'a+' would not be desirable because for 'a' and 'a+' there is a hidden fseek() to eof before every write.

サインインしてコメントする。


Jan
Jan 2018 年 1 月 12 日
Under Windows you can use https://www.mathworks.com/matlabcentral/fileexchange/24671-filetime to set the modification date manually.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by