CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I can`t create folder with mdd stack

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

I can`t create folder with mdd stack
PostPosted: Sun Jun 23, 2013 1:16 am     Reply with quote

Greatings! I`m using mplab 8.91 and ccs stack v4.134, mdd stack 2012-06-22. I can create files and add data to them, but when I try to create folder the FSmkdir(dir) returns 0 (as it has to be ex_fat)
Code:

   if(FSmkdir(dir))
   {
      printf("Error creating directory");
      return;
   }
   printf("OK");

But after that I don`t have folder in the card. I tried several definitions for dir:
Code:

char dir[]="Folder";
char dir[7]="Folder";

As I said I can create files and add data to them!
If I use FSmkdir("Folder") it`s OK!
What am I doing wrong? What error I`m doing with the dir variable?
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19329

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 1:50 am     Reply with quote

Have you done a Chdir first?.

If not, then your path should (must?) have a leading '\' to say 'put this in the root directory'. Otherwise it is created 'relative' to where Chdir selected, and unless you have used Chdir, it can go awry....
So try:
Code:


char dir[]="\Folder\";


I've had 'oddities' with this function in the past....

Best Wishes
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 2:39 am     Reply with quote

After calling FSInit(), the root directory is the current directory. In so far, FSmkdir("Folder") will work.
If the current directory is unknown and you want to create a folder in the root directory, a leading
backslash is required.

The MDD directory related functions don't expect a trailing backslash.

What is "mdd stack 2012-06-22", MDD V1.40?
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 2:59 am     Reply with quote

I fixed it! It seems I have to use a pointer to the char array when I`m using
FSmkdir in a function:
Code:

void FunctionName(char *dir)
{
 ....
}

Can I ask one more thing? Why I can`t use pic kit 3 debugger with this mmd stack? It always stops and returns pic kit 3 has halted with errors?
Thanks!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 10:12 am     Reply with quote

Quote:
I fixed it! It seems I have to use a pointer to the char array when I`m using FSmkdir in a function

Yes of course, as with any string argument. The problem was unfortunately hidden by the incompletely posted code.

Please notice that string objects like char[] or char[7] are equivalent to char*.

Quote:
Why I can`t use pic kit 3 debugger with this mmd stack? It always stops and returns pic kit 3 has halted with errors?

No idea, please post details. Which processor?
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 11:39 pm     Reply with quote

I'm using PIC18F66J60, Clock=10M, SD card 2G!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group