realbasic-plugins
[Top] [All Lists]

REALpathFromFolderItem and XCode

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: REALpathFromFolderItem and XCode
From: Brad Hutchings <brad at componentx dot com>
Date: Mon, 12 Feb 2007 10:06:19 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
A tip for anyone converting a CodeWarrior Mach-O plugin to XCode... REALpathFromFolderItem returns a path that works with CodeWarrior's fopen, but not XCode's. The path is an old-style Mac path (: separated), not a UNIX path that fopen expects. Am I missing an easier way of opening a file than I use below? Is there something here that should be feature requested? I get the string path, make a new string prepended by "/Volumes/", append the path, and convert ':'s to '/'s.

-Brad
--
Brad Hutchings
e-mail: brad at ComponentX dot com




REALfolderItem fi; // a parameter

REALstring path = REALpathFromFolderItem(fi);
if (path != NULL)
{
        const char* path_string = REALCString(path);
        if (path_string != NULL)
        {
                char* unix_path_string = malloc(strlen(path_string) + 100);
                if (unix_path_string != NULL)
                {
                        strcpy(unix_path_string, "/Volumes/");
                        strcat(unix_path_string, path_string);
                        
                        for (char* x = unix_path_string; *x != 0; x++)
                        {
                                if (*x == ':')  *x = '/';
                        }
                
                        file_ref = fopen(unix_path_string, "rb");
                        
                        free(unix_path_string);
                }
        }
}



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>