Make a hidden directory???

BlitzPlus Forums/BlitzPlus Programming/Make a hidden directory???

arget brisingr(Posted 2007) [#1]
Is there a way to make Account Files hidden?

CreateDir C:/Program Files/Admin-Z/Missions/
CreateDir C:/Program Files/Admin-Z/Account Files/
fileout = WriteFile("../Account Files/account.dat")
WriteLine(fileout,agentID)
WriteLine(fileout,agentTERMINAL)
WriteLine(fileout,agentPASS)
CloseFile fileout



Dabz(Posted 2007) [#2]
You can hide the file itself:-

//Creates a hidden file, which is handy for config settings etc etc
// E.g.		result = CreateHiddenFile(fileName$)
BBDECL BOOL BBCALL CreateHiddenFile( const char * fileName)
{
	HANDLE hFile; 

	//Check to see if file exists
	hFile = CreateFile(fileName,       
                GENERIC_WRITE,              
                0,           
                NULL,                     
                OPEN_EXISTING,           
                FILE_ATTRIBUTE_HIDDEN,    
                NULL);   
 
	//If not, create a new one
if (hFile == INVALID_HANDLE_VALUE) 
{ 
	hFile = CreateFile(fileName,   
             GENERIC_WRITE,   
             0,         
             NULL,      
             CREATE_ALWAYS,      
             FILE_ATTRIBUTE_HIDDEN,   
             NULL);  
	if (hFile == INVALID_HANDLE_VALUE) 
	{ 
        return(FALSE); 
	} 
}
		
		CloseHandle(hFile);
	return(TRUE);
}

//DECLS:-
//CreateHiddenFile%(filename$):"_CreateHiddenFile@4"


This is a userlib BTW...

I know you can get a handle to a directory using CreateFile, so it may be possible to create one with the FILE_ATTRIBUTE_HIDDEN flag just by passing the new folders path$... But dont quote me on that! :D

If not, just plonk the hidden files in your config folder or something, I mean, nobody is going to see them anyway are they! ;)

Dabz


arget brisingr(Posted 2007) [#3]
Okay thats great only I don't think it is in blitzplus....


kfprimm(Posted 2007) [#4]
Give me a second and I'll compile it for you.


kfprimm(Posted 2007) [#5]
Here. Get it soon cause I'm taking it down tonight. Oh, yeah just copy those files to C:\Program Files\BlitzPlus\userlibs\ (assuming you installed BlitzPlus to the program files.) And if you distribute your game/app make sure you put HiddenFile.dll in the same directory as your game/app exe.


arget brisingr(Posted 2007) [#6]
Alright I got it what do I open it with? I have blitzplus blitz3d and a demo if blitzmax


kfprimm(Posted 2007) [#7]
CreateHiddenFile is now a command you can use.


arget brisingr(Posted 2007) [#8]
Oh sweet. What dir do I save it as? userlib or something...


kfprimm(Posted 2007) [#9]
yep, stick those files in the userlib folder in your BlitzPlus installtion folder.


arget brisingr(Posted 2007) [#10]
Ok then I can make my thing like this:

createhiddenfile("../Account Files/account.txt")
fileout = writefile("../Account Files/account.txt")
WriteLine(fileout,agentID)
WriteLine(fileout,agentTERMINAL)
WriteLine(fileout,agentPASS)
CloseFile fileout


right...


kfprimm(Posted 2007) [#11]
Yes, it should work like that but I haven't tested it.


arget brisingr(Posted 2007) [#12]
It would be better if I could just make Account Files hidden...


Dabz(Posted 2007) [#13]
To be honest arget, I'd imagine you'll have a config folder or something similar, just your account files in there... Its not like people are going to see them is it! :D

I havent used this for ages because now I do stuff in Max, but try:-

createhiddenfile("../Account Files/")
createhiddenfile("../Account Files/account.txt")


I know you can get a handle for folders using the Win32's CreateFile, so you may be able to create them too with the hidden attribute.

Dabz