Invalid file properties returned by dir

5 次查看(过去 30 天)
So, I've been using dir to quickly get me a catalogue of all the file sizes of a specific type of file. My code works, however, there is one particular file, which returns into the output:
name: 'dagkgjkajk.his'
date: ''
bytes: []
isdir: 0
datenum: []
Does anyone know why this may be the case?
  14 个评论
Iain
Iain 2013-8-27
Ok, now, I'm REALLY confused. It has stopped doing it.
I can only assume that there is some jiggery-pokery going on behind the scenes by our IT guys.
dpb
dpb 2013-8-27
Ok, now, I'm REALLY confused. It has stopped doing it.
Ain't science wonderful!!??? :)
Doncha' just love it when these unexplainable anomalies occur? I'd guess that's as good an explanation as will ever come up with although there was a full moon the other night; that could well have had something to do with it as well...
Keep us posted if it comes/goes again and if there is any resolution other than the aforementioned "Stuff happens..."

请先登录,再进行评论。

采纳的回答

dpb
dpb 2013-8-23
编辑:dpb 2013-8-23
... why it is empty
That's up to whatever created it and/or left it that way.
Likely candidate would be an open w/ write permission subsequently closed w/o rewriting anything...
>> type fixed.dat
-1.6999E-3-1.3266E-3 1.2916E-3 3.5491E-4 1.1022E-3-9.5555E-4-3.9528E-4 3.5200E-4
>> fid=fopen('fixed.dat','w');
>> fid=fclose(fid);
>> d=dir('fixed.dat')
d =
name: 'fixed.dat'
date: '23-Aug-2013 07:51:02'
bytes: 0
isdir: 0
datenum: 7.3547e+05
>>
Note an existing file has been truncated. That yours has no creation date means it quite probably was an open of a previously non-existing file followed perhaps by an aborted operation before anything was written. For whatever reason, it was created by the file system but nothing is in it.
The problem isn't so much the file as the code that assumes there won't be such a thing existent--use try...catch block or an explicit test or somesuch to handle it cleanly.
  4 个评论
Walter Roberson
Walter Roberson 2013-8-23
Truncating the file contents is fine, but notice that the date itself is empty, and that "bytes" is not 0 but instead []. Such things are not supposed to be possible.
Windows has been POSIX compliant since Windows XP SP3.
dpb
dpb 2013-8-23
You're right, I noted the empty date but whiffed on the size being empty instead of zero--my bad, sorry.
I'd guess a failure occurred somewhere. "Stuff happens..." Maybe a network access went away at the critical moment or somesuch--I'd guess it'll not be possible to determine the actual "why" of the root cause at least w/o some detailed digging into it at the OPs site.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by