This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[scripting] Using QFile to read files

Tags: None
(comma "," separated)
fpe
Registered Member
Posts
15
Karma
0
OS

[scripting] Using QFile to read files

Fri Oct 30, 2009 12:21 am
I am trying to read some file's contents from within an Amarok script. I included qt.core bindings.

var myFile = new QFile(path);
Amarok.alert(myFile.size());

returns the correct size of the file stored at path.

However,
myFile.exists(path)
always returns false, and so does
myFile.open(1)

(I used the 1 for QIODevice::ReadOnly, since I do not know how to access this constant from JavaScript)

Does someone have a hint on how I can open and read binary files in an Amarok Script?

Tanks
fpe
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Does "path" contain a path to an actual file on disk?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fpe
Registered Member
Posts
15
Karma
0
OS
Yes.
The code did work in C++, now I'm trying to port it to Amarok Script.
fpe
Registered Member
Posts
15
Karma
0
OS
I finally found out how to correctly open a file for reading:

myFile.open(new QIODevice.OpenMode(QIODevice.ReadOnly));

Now it's working :)


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], markhm, Sogou [Bot], Yahoo [Bot]