Is there a way to get rid of the .DS_Store ??

BlitzMax Forums/BlitzMax Programming/Is there a way to get rid of the .DS_Store ??

wad(Posted 2011) [#1]
Here is my scenario :-

i am writing a drum machine software like the old specdrum software from the spectrum 48k but with new things added like midi and stuff but here is my question , on the mac in every folder created there is a file created called .DS_Store , this file is basically telling the mac whats in that folder and what associations it uses which program and whatever.

Now in my program i look into a folder where the .wav files are stored for the drum sounds and when i read the folder this .DS_Store file is read into the array i want to create.
when i use the readfile command it drags all in there into the array

here is my idea
for arguments sake


and so on

has anyone had this trouble before on the mac ??

Lee B

Last edited 2011

Last edited 2011


Oddball(Posted 2011) [#2]
Why don't you just ignore all files and folders that begin with a '.'.
If Left(file$,1)="." then 'Ignore me


Last edited 2011


GfK(Posted 2011) [#3]
As an aside, there are ways to disable creation of .DS_Store files. They're a particular pain in the arse when browsing a PC drive from your Mac, because it creates the damn things everywhere.

You can turn them off for network drives (recommended), or off completely (not recommended). Google it.


wad(Posted 2011) [#4]
thanks oddball for that i managed to work it out but yes gfk they are a pain in the butt and there are tweaks using the terminal app to get rid of them but they just seem to hide and then they re-appear but hey ho i have managed to sort it




ima747(Posted 2011) [#5]
Anything that begins with a . On a *nix type system (Linux, unix, Mac, et. al.) is designated as hidden. There are other ways to flag things hidden but it's a simple way to control visibility on a command line level. As a result of this, IMO the most prudent approach is to ignore things that should be invisible because you're not intended to play with them anyway.


Htbaa(Posted 2011) [#6]
It's also considered a hidden file for Windows by default.


wad(Posted 2011) [#7]
true the files are hidden but the blitzmax command readdir.... sees it still
i was working on another way like create a seq file to load the paths in so the program calls the seq file and loads them in respectively but that limits the user to creating there own directories and the program is too far gone to go re-arranging it all , its actually nearly finished but i was just getting this problem.

I never got this problem with windows even if the file was present....
maybe i could write a routine to just see .wav files as the extension because that's what the program uses 44khz 16bit samples.

cheers everyone :)

Lee


ima747(Posted 2011) [#8]
If you're only looking for one thing you should only look for one thing (i.e. .wav files) because someone WILL screw something up and put a PDF or something silly in there eventually.

Readdir shows the files because they exist. It would be nice if it defaulted to only visible files, but it shows everything because it doesn't know, maybe you want to find hidden files... It's your responsibility to narrow down from everything to what you need. I'm fairly sure there's a convenience method in the code archives that will parse readdir results for you, but it's not very complicated so it should be trivially simple to do it on your own (in your case, just loop the results looking if the file extension matches "wav"...) There's nothing build in because discarding information is the developer's responsibility since the tools can't inherently know what you want.

Additionally if you're only looking for wav's and there's any chance users might go monkeying with the directory structure you should validate the files before using them as well, it's pretty easy to slap .wav on the end of anything and if you try to load something it could get ugly... another good sanity check could be a file size check. If you're loading into ram and someone feeds it a 1gb movie file renamed as a wav bad things are going to happen...


wad(Posted 2011) [#9]
Ty ima747 for that interesting read , i understand where your coming from but like most software i.e software synths or drum machine softwares they use folders with either .wav files or in some cases they are mp3's or in a mac's case aiff's but i hear what ya saying and i will look in the code archives for a file extension checker, i have seen one in the past but it was a few months ago , it was a file requester snippet that someone had posted and that used a mask option to open a file requester with the ext of your choice.

on the pc i dont get this problem even with the .DS_Store file there it just sees my files but thanks again and i will keep looking and then i can get this project finished lol its all working apart from this little niggly bit :)

Lee


Oddball(Posted 2011) [#10]
If Lower(ExtractExt(file))="wav" Then 'I am a wave file
or
If "wav,mp3,ogg".Contains(Lower(ExtractExt(file))) Then 'I am an audio file


Last edited 2011


wad(Posted 2011) [#11]
interesting cheers oddball :)

will fit this in and see if it works , i mean i know it will :)

will let you know :)

Thanks

Lee B


wad(Posted 2011) [#12]
interesting but it did not work for me on the mac anyways it does on the pc no probs does what it says on the tin :) looks for wav files and thats it but the mac no way , here is another thing i tried and i dont know if this has anything to do with it but i changed my filenames to for example

.01 Bass Drum.wav and before it was 01 Bass Drum.wav

the mac then throws a wobbler and says the mac os will treat this file as a system file do you want to continue? i say yes and then the file greys out , this is not a problem but when i run my program guess what........ it works fine , a couple of days ago i did this solution on its own :-



This works fine but when i put that line in my bloody program ignores it lol its really doing my fruit in

This is only doing this on the mac grrrrrrr :)

Lee


Oddball(Posted 2011) [#13]
Hello again. The code below works fine on my Mac. Hope it helps.
SuperStrict

Local namestd:String[1]
Local jl:Int
jl=0
Local folder:String="\Applications\Specdrum\Kits\Standard" ' the folder
Local myDir:Int=ReadDir(folder$)

If myDir=0 Then RuntimeError folder+" does not exist!"
Local file:String=NextFile$(myDir)

While file
	If Lower(ExtractExt(file))="wav"
		namestd=namestd[..jl+1]
		namestd$[jl]=file$
		jl=jl+1
	EndIf
	file$=NextFile$(myDir)
Wend
CloseDir myDir

'here we print stuff
Graphics 1024,768

Cls
For Local i:Int= 0 Until namestd.length
	DrawText i+1+") "+namestd$[i],10,10+i*11
Next 

Flip

WaitKey()



wad(Posted 2011) [#14]
Thanks Dave , i will give it a try , i can see what you have done , you basically have turned it on its head as i was calling the dir command first now your calling it after hmmmmmmm will let you know :)

and using the while command :) excellent i should have thought of that

Lee B

Happy Holidays to you and ty for helping in this matter


wad(Posted 2011) [#15]
Just letting you know that worked a treat :)

Thank you to all that helped and put the code up for me it was just racking my brain but finally got there in the end :)

if i want to post my app can i post a link to it in here ????


so people can try it out :)

Lee