Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B

Created files are read only and invisible

Hi all.

 

My app needs to create some output files. I write the files to a subdirectory of the shared folder. I can see them with the file manager but I cannot view them, send them as attachments or view them from the PC.

Files I put in the same place with the PC are seen in my device and can be sent as mail attachments.

 

Trying to change file mode in my code doesn't have any effect. Files are still read only.

 

How can I create files in my c++ app that are writeable (and executable)?

 

Regards,

Mita

Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook

Re: Created files are read only and invisible

How are you trying to view them or view them on PC? Also post the code you are make using of
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B

Re: Created files are read only and invisible

First I used a third party library to create the file (some proprietary format), which is a single line of code that will tell you nothing.

 

Then, when this didn't work I experimented with a simple native fopen:

 

FILE *fp = fopen(pathname, "wb");

fwrite("testtesttest", 1, 10, fp);

fclose(fp);

 

And I also tried adding

chmod(pathname, 0777);   // also tried 0755 and other combinations

 

I can see the resulting file with the stock file manager.

 

On the PC I installed the latest link software, and I try to see the files using the windows explorer.

 

The other way around works - I use the windows explorer to put files in that folder.

 

 

Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook

Re: Created files are read only and invisible

The pathname will also matter. Also make sure your application has the required capabilities set in the bar-descriptor.xml.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B

Re: Created files are read only and invisible

The pathname points to shared/misc

 

but the bar-descriptor.xml directions sounds good.

 

Because I use a third party sdk, I don't have direct access to the bar-descriptor file, but the SDK does offer some higher level control, which I assume is implemented in that xml, and I did check the enable shared file access.

 

Is there another option in that xml I should use?

Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook

Re: Created files are read only and invisible

I am sure the problem is with permission related to your app and how much control is passed on by SDK. Take a simple helloworld example try to read and write file, it should work fine with the permissions set in bar-descriptor.xml.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B

Re: Created files are read only and invisible

I tried a simple do-nothing app. Didn't help.

 

Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook

Re: Created files are read only and invisible

do-nothing app means? Hope you have tried to write a file inside it. It should work. If not working just post the code you tried.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B

Re: Created files are read only and invisible

by do nothing I mean an app without gui that starts, writes the file, and exists. the code I used in its main function is what I wrote above. fopen, fwrite, fclose, chmod.

 

I can verify that it works because the file is created. Only problem is that it is created read-only and it is invisible to the PC as well as the other problems I described above.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Created files are read only and invisible


mita wrote:
I can verify that it works because the file is created. Only problem is that it is created read-only and it is invisible to the PC as well as the other problems I described above.

How are you proving to yourself that the file is created?

 

Can you see it on the device, using the File Manager app?


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.