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:
parent
34ce4c00f5
commit
3553b83806
@ -54,48 +54,23 @@ void InitializeWorkingDirectory(void)
|
|||||||
|
|
||||||
// Get the application bundle
|
// Get the application bundle
|
||||||
CFBundleRef MainBundle = CFBundleGetMainBundle();
|
CFBundleRef MainBundle = CFBundleGetMainBundle();
|
||||||
|
assert(MainBundle != NULL);
|
||||||
if (!MainBundle)
|
|
||||||
{
|
|
||||||
std::cerr << "Error getting the application main bundle" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the resource directory URL
|
// Get the resource directory URL
|
||||||
CFURLRef ResourceDirectory = CFBundleCopyResourcesDirectoryURL(MainBundle);
|
CFURLRef ResourceDirectory = CFBundleCopyResourcesDirectoryURL(MainBundle);
|
||||||
|
assert(ResourceDirectory != NULL);
|
||||||
if (!ResourceDirectory)
|
|
||||||
{
|
|
||||||
std::cerr << "Error getting the resource directory of the main bundle" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert it as absolute URL
|
// Convert it as absolute URL
|
||||||
CFURLRef AbsoluteURL = CFURLCopyAbsoluteURL(ResourceDirectory);
|
CFURLRef AbsoluteURL = CFURLCopyAbsoluteURL(ResourceDirectory);
|
||||||
|
assert(AbsoluteURL != NULL);
|
||||||
if (!AbsoluteURL)
|
|
||||||
{
|
|
||||||
std::cerr << "Error getting the resource directory as an absolute URL" << std::endl;
|
|
||||||
CFRelease(ResourceDirectory);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the POSIX style path
|
// Get the POSIX style path
|
||||||
CFStringRef AbsolutePath = CFURLCopyFileSystemPath(AbsoluteURL, kCFURLPOSIXPathStyle);
|
CFStringRef AbsolutePath = CFURLCopyFileSystemPath(AbsoluteURL, kCFURLPOSIXPathStyle);
|
||||||
|
assert(AbsolutePath != NULL);
|
||||||
if (!AbsolutePath)
|
|
||||||
{
|
|
||||||
std::cerr << "Error converting the resource directory URL as a POSIX path" << std::endl;
|
|
||||||
CFRelease(AbsoluteURL);
|
|
||||||
CFRelease(ResourceDirectory);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the path as C string and set it
|
// Get the path as C string and set it
|
||||||
if (CFStringGetCString(AbsolutePath, PathBuffer, 4096, kCFStringEncodingASCII))
|
assert(CFStringGetCString(AbsolutePath, PathBuffer, 4096, kCFStringEncodingASCII) == true);
|
||||||
chdir(PathBuffer);
|
assert(chdir(PathBuffer) == 0);
|
||||||
else
|
|
||||||
std::cerr << "Error copying the resource directory path in the C buffer" << std::endl;
|
|
||||||
|
|
||||||
CFRelease(AbsolutePath);
|
CFRelease(AbsolutePath);
|
||||||
CFRelease(AbsoluteURL);
|
CFRelease(AbsoluteURL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user