Jump to content

Recommended Posts

Posted

 

thats works:

FILE_DirExists("a");	// check for a Folder named a

 

get the warning: "warning: passing argument 1 of 'FILE_DirExists' makes pointer from integer without a cast [enabled by default]"

char directory = a
FILE_DirExists(directory);	// directory is a variable

 

is it possible to check for a Variable-Dir?

file.c says:

/////////////////////////////////////////////////////////////////////////////
//! Returns 1 if directory exists, 0 if it doesn't exist, < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 FILE_DirExists(char *path)
{
  DIR dir;

  if( !volume_available ) {
#if DEBUG_VERBOSE_LEVEL >= 2
    DEBUG_MSG("[FILE_DirExists] ERROR: volume doesn't exist!\n");
#endif
    return FILE_ERR_NO_VOLUME;
  }

  if( !path || !path[0] )
    return 0; // empty directory name - handle like if it doesn't exist

  return (file_dfs_errno=f_opendir(&dir, path)) == FR_OK;
}

 

Posted (edited)

i got it:

// change Folder Directory  -  letter loadet from previos loaded SYS-File
char Folder = 'a';
char path[8];
strncpy(path,  "a       ", 8);
path[0] = Folder;
										
statusDir 	= FILE_DirExists(path);	 		// ask file.c: exist a folder "a/" on the CARD? //

or:

char Folder = A’;
char path[8];
// Build File Path/0.t4      "
sprintf   (path, "%c/0.b4",Folder);

// ask file.c: exist a file "A/0.b4" on the CARD? // 
statusFile_patch = FILE_FileExists(path);	

and for delete all Files - and Directory(if all files are known and already deleted

// you need to delete each file on its own...
int c; for (c=0; c<256; c++)	{
																	
						char remove[9];
 						 // make a new filename depending on the counter value
						sprintf   (remove, "%c/%d.b4",Folder,c);

						// Remove FILEs
						MUTEX_SDCARD_TAKE;
											FILE_Remove(remove);
						MUTEX_SDCARD_GIVE;
					}

// Remove Directory (can only be done if it empty
									
	// build path
	char remove[8];

	sprintf   (remove, "%c",Folder);
									
	MUTEX_SDCARD_TAKE;
					FILE_Remove(remove);
	MUTEX_SDCARD_GIVE;	

whoud be interesting, how to delete a folder if the Files inside are not known?

Edited by Phatline

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...