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
| | |-+  can i read file from my plugin??
« previous next »
  • Print
Pages: [1]

Author Topic: can i read file from my plugin??  (Read 3794 times)

Offline restart

  • Member
  • *
  • Posts: 14
can i read file from my plugin??
« on: June 15, 2008, 04:22:49 AM »
i want to read file (such as .txt or .xml), how can i read it?? where i put the files in rockbox??

thank's for your help
regards all
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: can i read file from my plugin??
« Reply #1 on: June 15, 2008, 09:03:19 AM »
use the standard open() / read() functions.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline restart

  • Member
  • *
  • Posts: 14
Re: can i read file from my plugin??
« Reply #2 on: June 15, 2008, 09:57:37 PM »
Quote from: bluebrother on June 15, 2008, 09:03:19 AM
use the standard open() / read() functions.

where i must put my .txt file in rockbox??
Logged

Offline GodEater

  • Member
  • *
  • Posts: 2829
Re: can i read file from my plugin??
« Reply #3 on: June 16, 2008, 03:08:53 AM »
Anywhere you like.
Logged

Read The Manual Please

Offline restart

  • Member
  • *
  • Posts: 14
Re: can i read file from my plugin??
« Reply #4 on: June 17, 2008, 10:42:42 PM »
Quote from: bluebrother on June 15, 2008, 09:03:19 AM
use the standard open() / read() functions.

i've got errors in using open() and read () functions.

Code: [Select]
VirtualGuide.c:(.text+0x90): undefined reference to `open'
VirtualGuide.c:(.text+0x98): undefined reference to `strcpy'
VirtualGuide.c:(.text+0x9c): undefined reference to `read'

can you help me??
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: can i read file from my plugin??
« Reply #5 on: June 17, 2008, 11:18:48 PM »
Quote from: restart on June 17, 2008, 10:42:42 PM
Quote from: bluebrother on June 15, 2008, 09:03:19 AM
use the standard open() / read() functions.

i've got errors in using open() and read () functions.

Code: [Select]
VirtualGuide.c:(.text+0x90): undefined reference to `open'
VirtualGuide.c:(.text+0x98): undefined reference to `strcpy'
VirtualGuide.c:(.text+0x9c): undefined reference to `read'

can you help me??

Kind of hard without seeing the code, but I'm going to guess that you didn't try rb->open().
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: can i read file from my plugin??
« Reply #6 on: June 18, 2008, 01:23:59 PM »
There are several plugins accessing files so it shouldn't be hard to find examples. Plugins need to use the plugin API structure pointer for accessing core functions (that pointer is usually named "rb").
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline restart

  • Member
  • *
  • Posts: 14
Re: can i read file from my plugin??
« Reply #7 on: June 18, 2008, 06:01:22 PM »
i am so confused where i should put my files ???
can anyone help me? i am trying to open file but the path is always not right...

---------------------------------------------------------------------------------------------------

here it is my code
Code: [Select]
fp = rb->open("help.txt", O_WRONLY|O_CREAT);

and the errors
Code: [Select]
WARNING, bad file name lacks slash: help.txt
WARNING, bad file name lacks slash: help.txt
« Last Edit: June 18, 2008, 06:05:50 PM by restart »
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: can i read file from my plugin??
« Reply #8 on: June 18, 2008, 06:24:38 PM »
It's telling you you really dont have a file specified. A path to a file normally has various "slashes" (C:\Documents and Settings\Administrator), that's what the error is. It really doesnt matter where you put your files as long as they stay there and you dont just have the file name. Instead of "help.txt" you need to put a path to where the file is "/.rockbox/plugins/help.txt".
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: can i read file from my plugin??
« Reply #9 on: June 18, 2008, 06:38:25 PM »
Quote from: mschneider on June 18, 2008, 06:24:38 PM
A path to a file normally has various "slashes" (C:\Documents and Settings\Administrator), that's what the error is.
Err, those are backslashes. A backslash is an escape character in C, so if you want to access a file "c:\test.txt" you need to double the \ in the code, i.e. write "c:\\test.txt". But Rockbox internally uses forward slashes (and there is no drive letter), so you get something like in the last example.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: can i read file from my plugin??
« Reply #10 on: June 26, 2008, 09:27:03 PM »
How do you use the read function to read multiple lines from a file?
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: can i read file from my plugin??
« Reply #11 on: June 26, 2008, 09:30:53 PM »
Quote from: mschneider on June 26, 2008, 09:27:03 PM
How do you use the read function to read multiple lines from a file?

Read in characters and test them to see if they're '\n', count the new lines as you go until you've read however many lines you wanted.

Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: can i read file from my plugin??
« Reply #12 on: June 26, 2008, 09:44:52 PM »
So does read_line read to the first newline or the whole file?


EDIT: On second thought, what I would like to know is: Is there a function to read files character by character?
« Last Edit: June 27, 2008, 08:21:51 PM by mschneider »
Logged

Offline gnu

  • Member
  • *
  • Posts: 269
Re: can i read file from my plugin??
« Reply #13 on: June 30, 2008, 02:27:11 PM »
Yes: rb->read().
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  can i read file from my plugin??
 

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

Page created in 0.102 seconds with 14 queries.