Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Reading files?
« previous next »
  • Print
Pages: [1]

Author Topic: Reading files?  (Read 1953 times)

Offline motionman95

  • Member
  • *
  • Posts: 108
  • aka coderkid
    • coderkid
Reading files?
« on: March 10, 2009, 04:28:54 PM »
How do I read files? I keep trying with this:

Code: [Select]
textfile_text = rb->read("ABC.config");

But it isn't working. What am I doing wrong?
Logged
My MP3 Player: Sansa C250 (2GB)
OS: Win XP SP3

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Reading files?
« Reply #1 on: March 10, 2009, 06:01:54 PM »
Seriously. At this point it'd be really beneficial to you to stop, take two or three weeks to work through a thorough set of lessons to learn the fundamentals of C, then another week or two of just reading the Rockbox source, learning its structure, and learning how to search for function definitions and etc within it.

The questions you've been asking basically seem to suggest that you're just trying to guess your way through this. The purpose of our forums isn't to teach you how to program. This section is primarily for questions on how to get started compiling. It's expected that you'll have a basic knowledge of programming. At the very least, you should check out other parts of the code, see what they're doing, etc.
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Reading files?
« Reply #2 on: March 10, 2009, 07:35:20 PM »
Quote from: motionman95 on March 10, 2009, 04:28:54 PM
Code: [Select]
textfile_text = rb->read("ABC.config");

But it isn't working. What am I doing wrong?
The prototype for read() is completely different:
Code: [Select]
ssize_t read(int fd, void *buf, size_t count);
Plus, it doesn't look like you have opened the file or have a file descriptor yet.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline motionman95

  • Member
  • *
  • Posts: 108
  • aka coderkid
    • coderkid
Re: Reading files?
« Reply #3 on: March 10, 2009, 09:06:44 PM »
Quote from: Llorean on March 10, 2009, 06:01:54 PM
The questions you've been asking basically seem to suggest that you're just trying to guess your way through this.

Which is absolutely not the case. I know 6 languages:

CSS,
HTML,
XML,
Actionscript,
Javascript,
and AutoIt.

The closet language to C is javascript, and actionscript. I not guessing, it's just that I think rockbox would have a lot more developers if they wrote some documentation. Not that I haven't  manged without it, but still, it would help. I'll admit that I was lazy in this instance, and had only about 10 minutes to work on it. (I'm a very busy guy.)
Logged
My MP3 Player: Sansa C250 (2GB)
OS: Win XP SP3

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Reading files?
« Reply #4 on: March 10, 2009, 09:28:45 PM »
Knowing 6 languages, of which two are loosely like C in syntax, doesn't mean you aren't guessing.

The statement you tried in the first post in this thread was a guess. When you tried to add two strings together with a +, it was a guess. When you tried to use included functions like rb->kbd_input() you just guessed instead of looking at how they were used elsewhere and were told to look around the source afterward, which means it's surprising to me that you chose not to this time. Knowing more about C and its differences from the languages you know (which are significant) will help you a lot, as well as actually looking at how the functions are used elsewhere in the code.

As bluebrother mentioned, the prototype for the function you tried to use is completely different. A basic knowledge of C would've had you at least know what parameters were expected of the function.
« Last Edit: March 10, 2009, 09:54:44 PM by Llorean »
Logged

Offline motionman95

  • Member
  • *
  • Posts: 108
  • aka coderkid
    • coderkid
Re: Reading files?
« Reply #5 on: March 10, 2009, 11:42:05 PM »
Code: [Select]
	int fd;
char test[20];
char filename[] = PLUGIN_APPS_DIR "/RockLock.config";

fd = rb->open(filename, O_RDONLY);
rb->read(fd, test, sizeof(test));
rb->close(fd);
Logged
My MP3 Player: Sansa C250 (2GB)
OS: Win XP SP3

Offline AlexP

  • Global Moderator
  • Member
  • *
  • Posts: 3688
  • ex-BigBambi
Re: Reading files?
« Reply #6 on: March 11, 2009, 04:20:41 AM »
Quote from: motionman95 on March 10, 2009, 09:06:44 PM
it's just that I think rockbox would have a lot more developers if they wrote some documentation. Not that I haven't  manged without it, but still, it would help. I'll admit that I was lazy in this instance, and had only about 10 minutes to work on it. (I'm a very busy guy.)

Sadly, writing documentation is boring, and all of our developers are very busy people and doing this in their spare time for fun.  Perhaps once you get to know the code better, you would then start to document it some more?
Logged
H140, F60, S120, e260, c240, Clip, Fuze v2, Connect, MP170, Meizu M3, Nano 1G, Android

Offline motionman95

  • Member
  • *
  • Posts: 108
  • aka coderkid
    • coderkid
Re: Reading files?
« Reply #7 on: March 11, 2009, 08:08:26 AM »
Definitely.  :D
Logged
My MP3 Player: Sansa C250 (2GB)
OS: Win XP SP3

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Reading files?
« Reply #8 on: March 11, 2009, 01:31:13 PM »
Quote from: motionman95 on March 10, 2009, 09:06:44 PM
Which is absolutely not the case. I know 6 languages:
Really? Programming languages?

CSS Markup. Not a programming language.
HTML Markup.
XML Markup.
Actionscript Script language.
Javascript Script language
AutoIt Script language.

So what's the 6 languages here? Any compiled language among them?

Quote
(I'm a very busy guy.)
And developers here are not? How do you judge if they are or not?
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Reading files?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.087 seconds with 15 queries.