[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Mac OS help needed!
From:       Angus Leeming <leeming () lyx ! org>
Date:       2004-12-29 21:44:18
Message-ID: cqv8bk$8rq$2 () sea ! gmane ! org
[Download RAW message or body]

Andreas, Bennett, Jean-Marc, 

I wonder if you can help me out. I'm trying to write the function below. It
is meant to return a string that contains the absolute path to a
directory. Note that this directory need not yet exist.

string const get_default_user_lyxdir(string const & homedir)
{
        using support::AddPath;

#if defined (USE_POSIX_PACKAGING)
        return AddPath(homedir, string(".") + PACKAGE);
#elif defined (USE_WINDOWS_PACKAGING)
        return AddPath(win32_folder_path(CSIDL_APPDATA), PACKAGE);
#elif defined (USE_OSX_PACKAGING)
        ???
#endif
}

where PACKAGE is #defined in config.h
#define PACKAGE "lyx"

On a Posix-like machine (linux, darwin?, OS/2), a typical returned value
would be
 /home/USERNAME/.lyx
On a Windows machine, a typical returned value would be
 C:/Documents and Settings/USERNAME/Application Data/lyx
The path is "posixified" with directory separators as '/' rather than '\'
but is otherwise very Windows-specific.

I have two questions for Mac OSX.
1. What should a typical returned value be?
2. What's the code I need to return such a value?

Jean-Marc has suggested that I use FSFindFolder, but this fills an FSRef
variable with some opaque data usable only by the File Manager, not by me,
the user. See the FSFindFolder docs at http://tinyurl.com/5mvgn.
Nonetheless, a naïve implementation (mine) would be

        FSRef fsref;
        OSErr const error_code =
                FSFindFolder(kUserDomain,
                             kPreferencesFolderType,
                             kDontCreateFolder,
                             &fsref);

Is it possible to take this filled fsref variable and extract the absolute
path to the folder in question? What system function would I need to do
this?

Alternatively, it seems that I might use GetFolderName. (See the Functions
item (lhs menu) of http://tinyurl.com/4oybp.) 
        OSErr GetFolderName (
                short vRefNum,
                OSType foldType,
                short * foundVRefNum,
                StrFileName name);

This will fill "name" with the title of the folder specified in the
foldType and vRefNum parameters. However, I'm unsure whether the "name" is
relative to the folder of "foldType" and, if so, how to obtain the
absolute name.

Further, have I got the correct values with "kUserDomain" and
"kPreferencesFolderType"?

Basically, I'm looking for someone with access to a Mac to write the code
for me ;-)

Kindest regards,
Angus


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic