#14037 closed bug (invalid)

[find_directory] B_USER_DATA_DIRECTORY is NULL

Reported by: Janus Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Storage Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Calling the find_directory function with directory_wich set to B_USER_DATA_DIRECTORY return NULL

Change History (12)

comment:1 Changed 16 months ago by Janus

Very strange exists a B_USER_NONPACKAGED_DATA_DIRECTORY I think it shouldn't. I found that B_USER_NONPACKAGED_DATA_DIRECTORY return /boot/home/config/non-packaged/data

What is the use for B_USER_DATA_DIRECTORY?

Last edited 16 months ago by Janus (previous) (diff)

comment:2 Changed 16 months ago by humdinger

B_USER_DATA_DIRECTORY should return /boot/home/config/data...

I wonder why there's no B_USER_APPS_DIRECTORY and some others.

comment:3 Changed 16 months ago by humdinger

I meant B_USER_NONPACKAGED_APPS_DIRECTORY in the above comment...

comment:4 Changed 14 months ago by Janus

In the irc jessicah has pointed out that the command finddir works as expected with B_USER_DATA_DIRECTORY. I have investigated the problem and the different behavior between terminal and applications is very simple to explain. The command calls the function with the parameter createIt sets to false, the applications with the parameter sets to true, the directory /boot/home/config/data doesn't exist and the directory /boot/home/config is read-only.

This should explain why the function doesn't work.

Last edited 14 months ago by Janus (previous) (diff)

comment:5 Changed 14 months ago by Janus

Add

AddDirectoryToHaikuImage home config data ;

to /haiku/build/jam/images/definitions/common-tail

Should do the trick. I hope.

comment:6 Changed 14 months ago by Janus

Shall we remove the directory_wich B_USER_NONPACKAGED_DATA_DIRECTORY?

comment:7 Changed 14 months ago by jessicah

I think what we probably need to do is investigate changing the behaviour of our constants.

E.g. constants like B_USER_DATA_DIRECTORY point to the non-packaged locations, and use B_USER_PACKAGED_DATA_DIRECTORY instead. We'd probably want to maintain the B_USER_NONPACKAGED_DATA_DIRECTORY as a synonym for B_USER_DATA_DIRECTORY.

The defaults are currently somewhat backwards, in that you end up with read-only locations by default, which would also be a problem for BeOS binary compatibility, IMO.

comment:8 in reply to:  7 Changed 14 months ago by Janus

Replying to Jessica:

I think what we probably need to do is investigate changing the behaviour of our constants.

I agree.

E.g. constants like B_USER_DATA_DIRECTORY point to the non-packaged locations, and use B_USER_PACKAGED_DATA_DIRECTORY instead. We'd probably want to maintain the B_USER_NONPACKAGED_DATA_DIRECTORY as a synonym for B_USER_DATA_DIRECTORY.

I don't know because when I think to the NONPACKAGED structure I think to something used for backward compatibility. In the future I hope all the new applications will use the packaged structure. So B_USER_PACKAGED_DATA_DIRECTORY should not exist.

The defaults are currently somewhat backwards, in that you end up with read-only locations by default, which would also be a problem for BeOS binary compatibility, IMO.

B_USER_DATA_DIRECTORY is not read only his parents is read only. It is the same for B_USER_SETTINGS_DIRECTORY. The problem is nobody has added this directory to the config directory.

comment:9 Changed 14 months ago by pulkomandy

The correct way to handle this is to use BPathFinder / find_path, which use a different set of constants (B_FIND_PATH_*, defined in https://git.haiku-os.org/haiku/tree/headers/os/storage/FindDirectory.h#n134). The whole find_directory API will be deprecated at some point (likely in R2, and then removed in R3?).

We should write docs for BPathFinder, however!

Also, BeOS didn't have a B_USER_DATA_DIRECTORY, so I wonder how we could hit a binary compatibility problem there: https://github.com/jscipione/r5headers/blob/master/headers/be/storage/FindDirectory.h (that may still apply to other directories, however).

Last edited 14 months ago by pulkomandy (previous) (diff)

comment:10 Changed 14 months ago by Janus

The problem persists with BPathFinder. The directory /boot/home/config/data doesn't exist and /boot/home/config/ is readonly...

So even with BPathFinder is impossible to access the B_FIND_PATH_DATA_DIRECTORY.

To fix this we must create the directory as explained in comment:5

comment:11 Changed 14 months ago by pulkomandy

Yes, indeed. I was just referring to Jessica's comment that the find_directory constants should be changed.

However, what would be the point of creating an empty directory where no one can write? If some software bundles data, it will comme with its own data directory in the package, and then if it uses BPathFinder or find_directory, it will find it. Otherwise, the directory is not used, and there is no point in creating it.

comment:12 Changed 11 months ago by Janus

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.