QDir::entryInfoList() return is 0?
-
QDir root("/"); qDebug()<<"app start"; QFileInfoList list_file=root.entryInfoList(); qDebug()<<list_file.length(); for(int i=0;i<list_file.length();i++){ qDebug()<<list_file[i].fileName()<<list_file[i].filePath(); }
//I need to list all the files in the root directory, I don't know what to do.
-
clickable desktop Return result
app start
21
"." "/."
".." "/.."
"bin" "/bin"
"boot" "/boot"
"dev" "/dev"
"etc" "/etc"
"home" "/home"
"lib" "/lib"
"lib64" "/lib64"
"media" "/media"
"mnt" "/mnt"
"opt" "/opt"
"proc" "/proc"
"root" "/root"
"run" "/run"
"sbin" "/sbin"
"srv" "/srv"
"sys" "/sys"
"tmp" "/tmp"
"usr" "/usr"
"var" "/var"The real machine returns to 0
-
@wangqinfeng what do you mean by the "Real Machine"? If you mean the UT phone, then probably you'd need to include in your .apparmor file the adequate policy group to grant permission to access the root folder. Have a look at the Apparmor Policy Groups to find out more.
-
Why does your app need to traverse the entire filesystem?
Apps in UT are confined. Your app only has access to its own data/config/cache directories. It cannot access arbitrary files on the system, for security/privacy.
-
@dobey Thank you! I want to use my app like a computer!
-
@matteo
Thank you for your answer! I want to compile the program on my ubuntu computer to run on my phone. -
Is this an app for personal use or are you planning to publish it to the OpenStore at some point?
-
@arubislander Good morning, this is a program I use myself, which is convenient for my management of the server.
-
@wangqinfeng Ah, then hack away to your heart's content!
-
@wangqinfeng said in QDir::entryInfoList() return is 0?:
@dobey Thank you! I want to use my app like a computer!
Apps are confined on the phone and cannot access arbitrary files or directories outside of the app's confinement.
You say you want to use it to manage the server, so is what you want to access the root filesystem on that server, rather than on your phone? Or are you trying to turn your phone into some sort of server?
It's difficult to provide direction, when we can't understand what you're trying to do exactly.