Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Jazz00006 on August 29, 2006, 05:39:13 PM

Title: Requesting Coding help
Post by: Jazz00006 on August 29, 2006, 05:39:13 PM
Well, i was making my own plugin, and im not the best @ C, and i was wondering if it was possible for me to get some help?

I don't want to post anything just yet, incase this might not be allowed.


But, is there a simplified list of the API calls you can make, and their corrent syntax, because i followed the tutorial, HowtoWritePlugins and it says to take a look @ plugin.h, but i cant read it properly, (becuase its not formated for easy reading IMHO.
Title: Re: Requesting Coding help
Post by: saratoga on August 30, 2006, 09:09:25 AM
You should probably ask more specific questions, or check out the IRC channel.  Or both.

BTW, you're allowed to post code.  Its all under GPL.
Title: Re: Requesting Coding help
Post by: Jazz00006 on August 31, 2006, 12:47:13 AM
thanx, im off to the irc right now :)
Title: Re: Requesting Coding help
Post by: Rincewind on August 31, 2006, 01:11:31 PM
It is always a good idea to look at plugins made by others and "steal" the button handling, LCD code, etc. from there  :)
Title: Re: Requesting Coding help
Post by: Jazz00006 on August 31, 2006, 09:41:44 PM
 :D

ok then, ive got my program working (to the extent of showing a splashscreen, and some text, what i wanted to know is;

How would i make a function that looked for a particular file;
i have no C coding experiance (well, not that much) so ill write it in english/basic/c (ish?)

If_file_exists as boolean (filepath)
{
blah, looking for file.
found{If_file_exists = true
}else{
If_file_exists = false
}
}

is there any way i can do that? (im going to look @ more 'basic' tutorials soon)
Title: Re: Requesting Coding help
Post by: saratoga on August 31, 2006, 09:59:12 PM
dir.c defines a funtion readdir function that returns a list of directory contents.  I haven't used it, but it seems like it would be ok.

Does you function need to search subdirectories?  If not, then just get the file list and see if its there.  If yes, then after that step, call the function recursively on each of the directories in the folder.  I don't think you can recurse all that much on embedded systems, but theres not all that many directories in Rockbox anyway, so it'd probably be ok.  
Title: Re: Requesting Coding help
Post by: Jazz00006 on August 31, 2006, 10:16:02 PM
yeah, i guess it needs the readdir, for (.rockbox/rocks) then find the file. i was gonna try and make it find

.rockbox/rocks/dummy.rock FYI


working on it now
Title: Re: Requesting Coding help
Post by: Jazz00006 on August 31, 2006, 10:28:10 PM
this is what i have got so far... havent tested it yet

i know thats a butched copy of the disktidy, but its all i have to go off at the moment


updated trial script(test2)

[attachment deleted by admin, too old]
Title: Re: Requesting Coding help
Post by: LinusN on September 01, 2006, 01:32:00 AM
I think you should ask yourself why you want to look for the file instead of just trying to open it and use it. A quick example of what I mean:

Code: [Select]

char buffer[256];
int f, rc;
f = rb->open("/.rockbox/rocks/myrock.rock", O_RDONLY);
if(f < 0) {
   rb->splash(HZ, true, "Can't open file");
} else {
   rc = rb->read(f, buffer, 256);
}

etc...

Title: Re: Requesting Coding help
Post by: Jazz00006 on September 01, 2006, 02:20:33 AM
meh, what you have does the job  :D

i only wanted to check for the file, not run it at first, then i was going to learn how to run it :)


thanx alot
Title: Re: Requesting Coding help
Post by: Travis on September 01, 2006, 09:10:35 PM
Quote
...is there a simplified list of the API calls you can make, and their corrent syntax


This is a really good idea, i'll look into it.  

It should probably be a wiki page. :)
Title: Re: Requesting Coding help
Post by: Jazz00006 on September 02, 2006, 01:15:36 AM

Quote
...is there a simplified list of the API calls you can make, and their corrent syntax


This is a really good idea, i'll look into it.  

It should probably be a wiki page. :)


Yeah please do :)

This is what i have so far, with a bit more help from other files :)
(Redone)

but when it comes to saving the file, all i get is a weird char, not the ones i write, can anyone help me now?


[attachment deleted by admin, too old]