Using assertions instead of cerr logging.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1030 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
ceylo 2009-02-28 21:00:59 +00:00
parent 34ce4c00f5
commit 3553b83806

View File

@ -54,48 +54,23 @@ void InitializeWorkingDirectory(void)
// Get the application bundle
CFBundleRef MainBundle = CFBundleGetMainBundle();
if (!MainBundle)
{
std::cerr << "Error getting the application main bundle" << std::endl;
return;
}
assert(MainBundle != NULL);
// Get the resource directory URL
CFURLRef ResourceDirectory = CFBundleCopyResourcesDirectoryURL(MainBundle);
if (!ResourceDirectory)
{
std::cerr << "Error getting the resource directory of the main bundle" << std::endl;
return;
}
assert(ResourceDirectory != NULL);
// Convert it as absolute URL
CFURLRef AbsoluteURL = CFURLCopyAbsoluteURL(ResourceDirectory);
if (!AbsoluteURL)
{
std::cerr << "Error getting the resource directory as an absolute URL" << std::endl;
CFRelease(ResourceDirectory);
return;
}
assert(AbsoluteURL != NULL);
// Get the POSIX style path
CFStringRef AbsolutePath = CFURLCopyFileSystemPath(AbsoluteURL, kCFURLPOSIXPathStyle);
if (!AbsolutePath)
{
std::cerr << "Error converting the resource directory URL as a POSIX path" << std::endl;
CFRelease(AbsoluteURL);
CFRelease(ResourceDirectory);
return;
}
assert(AbsolutePath != NULL);
// Get the path as C string and set it
if (CFStringGetCString(AbsolutePath, PathBuffer, 4096, kCFStringEncodingASCII))
chdir(PathBuffer);
else
std::cerr << "Error copying the resource directory path in the C buffer" << std::endl;
assert(CFStringGetCString(AbsolutePath, PathBuffer, 4096, kCFStringEncodingASCII) == true);
assert(chdir(PathBuffer) == 0);
CFRelease(AbsolutePath);
CFRelease(AbsoluteURL);