Hello. I’m trying to read the content of .DS_Store file to store it later into a database.
I’m using binary stream to read:
[code] dim b as BinaryStream
dim data as String
Try
b = BinaryStream.Open(f,false) // <–Break here, trying to open file.
data = b.Read(b.length)
if b.ReadError then
MsgBox("Error reading")
end if
b.close
return data
catch err as IOException
MsgBox “an IO exception occurred:” + err.Message + " num: " + str(err.ErrorNumber)
end try[/code]
I got Exception numer = 2 . I see in the file properties readable is false … there is away to force reading or a workaround, maybe using Cocoa Apis ?
Thanks in advance.
Sierra and beyond won’t even have them
Once the new file system will be released.
In this point of view, my concern is do you have the .DS_Store file format ?
About your code:
You forgot to share Dim f As FolderItem
Read the whole file in a variable is against the BinaryStream idea (b.Read(), b.ReadBoolean, b.ReadInt16, etc.).
Here the errors from your code are:
data = b.Read(b.length)
return data
data is not declared. Once Dimmed, it works. The code below “works”, but how usefull is it ? And it does not let me see the invisible files.
[code] dim b as BinaryStream
dim fLen As UInt64
dim data as String
Dim f As FolderItem
f = GetOpenFolderItem(“”)
Try
b = BinaryStream.Open(f, False) // <–Break here, trying to open file.
fLen = b.length
data = b.Read(fLen)
if b.ReadError then
MsgBox("Error reading")
end if
b.close
TA_XML.Text = data // TA_XML is a TextArea, used for simple report
catch err as IOException
MsgBox “an IO exception occurred:” + err.Message + " num: " + str(err.ErrorNumber)
end try[/code]
[quote=301457:@Dave S]* dont mess with changing anything about a .DSTORE file… it could make Finder very upset
I also wouldn’t get hung on on this file, as I undertstand that Sierra and beyond won’t even have them[/quote]
Sierra and El Captain still have these files… the Finder will never show them …
From
Hello,
on El Capitan I can make .DS_Store files visible with the help of the application Tinkertool (http://www.bresink.com/osx/TinkerTool.html).
Start Tinkertool, go to the Finder-tab, check Show hidden and system files and press the Relanch Finder-button.
I do not have Sierra installed, so I do not know if this works there too.
■■■■■■■■ as many other sentences all over the internet and not only in .DS_Store cases.
As delivered, invisible files are invisibles (in the Finder). The only way to make them visibles is to use a special software (how do it do that ?) OR to change their file name (usually removing the leading dot, but not only).
Also: you cannot add a leading dot to a file (folder) in / from the Finder: the action is rejected.
How the future will be ? Who knows. No more .DS_Store in the new macOS sile system ? Why not, but what will replace it ?
About OS changer applications
Since the old days of After Dark, (nearly 30 years ago) I stopped to use third party OS changers (like but not only: TinkerTool): they may works (from some seconds to some OS versions), but they also can crash.
At last, showing invisible files is like displaying file (folders) extension: if you do not know what to do with them, this is useless.
Question: do you know how many invisible files there is in a macOS initialized SD-Card ?
Back to the subject:
a. Opening .DS_Store is one thing, but without its internal schema composition (what Long at $0100 means ?) you can do nothing.
b. Reading the whole file is the wrong way: use BinaryStream specific Method build to do read Long, String, etc.
[quote=301482:@Christian Mézes]Hello,
on El Capitan I can make .DS_Store files visible with the help of the application Tinkertool (http://www.bresink.com/osx/TinkerTool.html).
Start Tinkertool, go to the Finder-tab, check Show hidden and system files and press the Relanch Finder-button.
I do not have Sierra installed, so I do not know if this works there too.[/quote]
In Sierra It must works the same. Our Xojo Thinkertool:
I also solved my issue. It was a path issue when going to read binary file because ‘nativepath’ mode doesn’t worked for me.
Here the working project:
@Schwartz
.DS_Store Files can be opened and manipulated…maybe not yet in xojo. There is good library to achieve this task in Python…
this is the URL . Maybe someone skilled with Python could make a xojo porting…
That’s your opinion. I personally prefer to read the entire thing, because it is much more efficient. If you prefer to use the BinaryStream methods to pick the file apart, you can read the entire file into a MemoryBlock and open a binarystream on the memoryblock. That way, all your operations are in memory.
Either one still requires you to know the file format regardless of on disk or in memory
And since .DS_Store is in an undocumented format Apple could change it on a whim and break whatever software relies on it’s current format
Tim, Norman:
Its OK for me: MemoryBlock have similar Read commands / File Format is undocumented AFAIK.
Invisible files:
A friend of mine have on a Windows XP a virus that hides all copied files to MemoryStick. I wrote a simple AppleScript that allows me to select the original invisible (and not the lnk file) file and copy it into my MacBook Pro to be used (a sqlite file): it is visible on OS X.
I tried to remove that virus (using a Windows script like icon), but I failed by lack of Windows knowledge.
I nearly forgot:
.DS_Store file is created only when you open the folder. Otherwise nothing is done even if you copy / move files in that folder. Windows do the same with Thumbs.db.
Why ? THere is nothing to store in the files if the folder is not opened (or the folder is empty). This is how it works (worked).
Remember: Urban Legends exists for everything (unlike proofs, evidences). The more unknow (or undocumented),the domain is, the more Urban Legends will talk (and nearly always wrong) about. So, before writing / giving clues (links), check if this is true or not.
A tuple seems to be an enum (for us Xojo developer and some others like C )
The pdf document is very scarce about the .DS_Store file format, but until a real run of code, it will still be that. Maybe running the code reveal some useful result.
But now, we know the next Apple file system (APFS) will not use .DS_Store files, how useful is this ?
You will be able to understand faster what is in the file. For example:
$0000: 00 00 00 01: # of description file(s)
$0014: 00 00 00 87 : adress of the file name (LString)
$00D0: 62 6C 6F 62 00 00 00 10 00 00 00 F9 00 00 00 4C blob…L
00 00 00 F9 and 00 00 00 4C are the x,y item position
position: {249, 76} [this comes from a Script]
Nota: the first space after the file position ($0000), is a Tab, while because of the strange TextArea implementation, I had to place a space between the Hex and ASCII parts ( a tab there moves the remainding of the paragraph in the next line (: ).
In what you report in the TextArea are descriptions I saw in a Preferences plist (com.apple.finder something). Phis plist can be opened using XCode.
The Hex / ASCII above comes from a .DS_Store stored in a folder with a single file (your project as zip).