Reply
Thread Tools
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#1
Hi, when I run this code program crash. In scratchbox is all ok but in real device no. File save.txt is saved in /home/usr/.app/
Code:
FILE *file = fopen("/home/usr/.app/save.txt","w");
I tryed, but It crash too.
Code:
FILE *file = fopen("save.txt","w");
What is wrong? THX fr your replies.
 
jaeezzy's Avatar
Posts: 664 | Thanked: 160 times | Joined on Jul 2008 @ Australia
#2
Are you sure its this line thats causing the trouble? Are you checking the returned pointer "file"? BTW, I think you are trying to write "/home/user...." whats the error message?
 

The Following User Says Thank You to jaeezzy For This Useful Post:
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#3
I am sure. I dont know what return file because app crashed. Thx for your time.
 
spanner's Avatar
Posts: 253 | Thanked: 184 times | Joined on Nov 2009 @ Bristol, UK
#4
Originally Posted by Figa View Post
I am sure. I dont know what return file because app crashed. Thx for your time.
If you are sure, then this:

Code:
#include <stdio.h>
int main()
{
  FILE *file = fopen("/home/usr/.app/save.txt","w");
}
will also crash. Please test this. If it crashes, then I am sure someone will help you. If it doesn't, then you haven't provided enough information.
 
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#5
fopen doesnt open this file and pointer is empty. I am sure that the file exists. Where is problem?
 
spanner's Avatar
Posts: 253 | Thanked: 184 times | Joined on Nov 2009 @ Bristol, UK
#6
Originally Posted by Figa View Post
fopen doesnt open this file and pointer is empty. I am sure that the file exists. Where is problem?
Where? I suspect between chair and keyboard. Didn't you read jaeezzy's post pointing out that you're writing "/home/usr" rather than "/home/user"?

If you really have created a directory called /home/usr/.app (why would you do that?), then:
a) sorry
b) please don't release an app that writes to this crazy location
c) paste the output of the command
Code:
ls -l -R /home/usr/.app
so that we can check for appropriate file permissions
 
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#7
-rw-r--r-- 1 root root 0 Feb 16 14:48 candidates.txt
-rw-r--r-- 1 root root 0 Feb 16 14:52 resources.rcc
-rw-r--r-- 1 root root 0 Feb 16 14:54 save.txt
 
spanner's Avatar
Posts: 253 | Thanked: 184 times | Joined on Nov 2009 @ Bristol, UK
#8
OK, 2 more questions:
1) are you running the app as 'root', or as 'user'?
2) can you also paste the output of the command
Code:
ls -l -d /home/usr/.app
 
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#9
As user.
drwxr-xr-x 2 root root 4096 Mar 1 18:35 /home/usr/.app

THX /home/user/.app is better?
 
spanner's Avatar
Posts: 253 | Thanked: 184 times | Joined on Nov 2009 @ Bristol, UK
#10
Originally Posted by Figa View Post
As user.
drwxr-xr-x 2 root root 4096 Mar 1 18:35 /home/usr/.app
The ls output shows that you have created the directory /home/usr/.app (and the files within it) as root. So neither the directory, nor the files in it, have write access for 'user'.

if you do
Code:
chown -R user.user /home/usr/.app
to change ownership of the files, you'll find that 'user' now has access to them.

Originally Posted by Figa View Post
THX /home/user/.app is better?
Yes, much better. That's the normal place to put application config information, and it goes on the same partition as /opt, so it doesn't use space on the root filesystem.
 
Reply


 
Forum Jump


All times are GMT. The time now is 18:19.