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
My Carrier: none yet

Re: Created files are read only and invisible

yes.

 

also, I can compose an email and then select it as attachment, but email containing attachments from files I create are never sent, as opposed to email without attachments or with attachments of files I didn't create

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

Re: Created files are read only and invisible

It might help if you could SSH into the device, and use the command line tools to inspect the file in question, and its parent folder(s) up to the level of /accounts/1000/shared.

You can also do this using the device filesystem navigator in Momentics (which basically does the same thing).

Look at both the permission bits and the group and user ownership. I would expect that, whatever the issue is, it will be apparent once you've gone through that, or have posted the data here.

The filesystem permissions and ownership stuff works basically like on any Posix system. For example, if the parent folder is not readable by the appropriate group or "other", then the files within it won't be visible via the Samba share.

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.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B
My Carrier: none yet

Re: Created files are read only and invisible

I cannot use Momentics because I use Marmalade, so I did the SSH stuff, and got this:

 

For the folder:

drwxrws---   2 100881000 1000_shared      4096 Jun 28 06:15 MyOutputFolder

 

For the file:

-rw-------   1 100881000 1000_shared     55185 Jun 27 19:38 file.bin

this only verifies the problem, but how do I change the permissions for group and world if the chmod and chown functions don't do anything not for the folder and not for the file?

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

Re: Created files are read only and invisible


mita wrote:
For the folder:

drwxrws---   2 100881000 1000_shared      4096 Jun 28 06:15 MyOutputFolder

 

For the file:

-rw-------   1 100881000 1000_shared     55185 Jun 27 19:38 file.bin

this only verifies the problem, but how do I change the permissions for group and world if the chmod and chown functions don't do anything not for the folder and not for the file?


They must work. Your app owns both the folder and the file, so if you use those routines properly they must let you modify the permissions. I'm not sure about changing ownership... there may be restrictions on what you can change it to, but you shouldn't have to for your purposes either. Just add "group" or "other" read/write permissions with chmod() and I can't see how it wouldn't work.

 

Post the code you're trying to use, if it's not working. Maybe some reason will be apparent to me or others.


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.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Created files are read only and invisible

This looks like a bug in Marmalade. It provides multiplatform implementation for all these functions and chmod etc may not be implemented at all. I guess this is your thread on Marmalade forums:

https://devnet.madewithmarmalade.com/questions/13151/files-written-in-qnx-are-invisible-and-savepng-...

Try contacting them by email, previously I asked their developer relations team for help regarding unanswered forum post and they escalated it to developers internally.

 

Theoretically it's possible to workaround the issue by creating a custom platform extension and using platform-specific APIs directly, but I haven't dug into this.

 

Before contacting them I suggest creating a simple test project in Momentics to make sure that the problem is indeed in their SDK.


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook
My Carrier: Loop

Re: Created files are read only and invisible

Mita,

I was actually suggesting you to try using Momentics IDE only and not depend upon Marmalade. This way you can make sure if the issue is with Marmalade. Because with Momentics IDE, I never faced any issue in file creation.
----------------------------------------------------------
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
My Carrier: none yet

Re: Created files are read only and invisible

You're right, of course, but the point of this journey I took with BB is because of the option to reuse my Marmalade code without learning a new SDK.

 

I'm sure it'll work with Momentics, but that won't help me one bit if I'm not going to actually develop with it...

 

btw - with momentics - where do you put your files? is the shared folder really the only option?

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

Re: Created files are read only and invisible

Unless you're creating files that the user should be able to read outside your program, such as images or .doc files and such things, you generally would want the data to be stored in the app's own "sandbox" data area, which isn't accessible *at all* outside your app (including over wifi). Given the standard working folder (current directory) for an app when it starts, this data folder is always just at "./data" (i.e. a subfolder of the working folder, named "data"). The relative path to the shared (wifi-accessible) folders is a sibling of this, specifically a symbolic link (named "shared") that points to /accounts/1000/shared.

For more background see https://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.d...

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.
Contributor
mita
Posts: 13
Registered: ‎06-29-2013
My Device: dev alpha B
My Carrier: none yet

Re: Created files are read only and invisible

yes, I've been to that doc page.

 

writing to the private data area is indeed no problem, but I want to create public files, available to send as email attachments or any other way to transfer to other people, and while the doc says that I can use one of the subfolders of the shared virtual link, it doesn't work.

 

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

Re: Created files are read only and invisible

[ Edited ]

If I haven't said, I know nothing about Marmalade so I can't help with (probable) bugs in it. If it provides access to a (maybe broken) chmod, however, then it might also provide you with a umask() routine. (?)

If so, that might help as it would let you change the default mode for files you create. Note that the bits are sometimes inverted, as they're used to mask out the permission bits (from a starting point of octal 777) rather than to directly set them.

Alternatively, can you run arbitrary command line programs from within the app? You could use a "system" call to run the umask utility directly and grab/log whatever it returns. That might reveal something.

 

In a native app here, "umask" returns 002 (world-writable bit masked out) and creating a folder and a file within it in shared/misc gives me full read/write for the group and read access for everyone.  (Edited: at first I ran this in a devmode app, and umask was 000 there so for a signed app it's a bit different.)

 

$ ls -lR shared/misc/testfolder

shared/misc/testfolder:
total 16
drwxrwsr-x   2 100611000 1000_shared      4096 Jul 02 15:06 .
drwxrws---  14 root      1000_shared      4096 Jul 02 15:06 ..
-rw-rw-r--   1 100611000 1000_shared         0 Jul 02 15:06 testfile

$ cat shared/misc/testfolder/testfile
umask returned 002

 

The lack of a world-writable bit in my folder and my file presumably corresponds to the fact that the system has set umask to 002 for me. (At least, I didn't do it in my code.)


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.