#include <stdio.h>
#include <errno.h>
-#if defined(Q_OS_MAC)
-# include <qcore_mac_p.h>
-#endif
-
-#if defined(Q_OS_MAC)
-# include <CoreFoundation/CFBundle.h>
-#endif
-
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_MAC)
-static inline bool _q_isMacHidden(const char *nativePath)
-{
- OSErr err;
-
- FSRef fsRef;
- err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(nativePath),
- kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0);
- if (err != noErr)
- return false;
-
- FSCatalogInfo catInfo;
- err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
- if (err != noErr)
- return false;
-
- FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo);
- return (fileInfo->finderFlags & kIsInvisible);
-}
-
-static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &entry)
-{
- if (!data.isDirectory())
- return false;
-
- QFileInfo info(entry.filePath());
- QString suffix = info.suffix();
-
- if (suffix.length() > 0) {
- // First step: is the extension known ?
- CFStringRef extensionRef = QCFString::toCFStringRef(suffix);
- CFStringRef uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL);
- if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle))
- return true;
-
- // Second step: check if an application knows the package type
- CFStringRef path = QCFString::toCFStringRef(entry.filePath());
- QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true);
-
- UInt32 type, creator;
- // Well created packages have the PkgInfo file
- if (CFBundleGetPackageInfoInDirectory(url, &type, &creator))
- return true;
-
- // Find if an application other than Finder claims to know how to handle the package
- QCFType<CFURLRef> application;
- LSGetApplicationForURL(url,
- kLSRolesEditor|kLSRolesViewer|kLSRolesViewer,
- NULL,
- &application);
-
- if (application) {
- QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);
- CFStringRef identifier = CFBundleGetIdentifier(bundle);
- QString applicationId = QCFString::toQString(identifier);
- if (applicationId != QLatin1String("com.apple.finder"))
- return true;
- }
- }
-
- // Third step: check if the directory has the package bit set
- FSRef packageRef;
- FSPathMakeRef((UInt8 *)entry.nativeFilePath().constData(), &packageRef, NULL);
-
- FSCatalogInfo catalogInfo;
- FSGetCatalogInfo(&packageRef,
- kFSCatInfoFinderInfo,
- &catalogInfo,
- NULL,
- NULL,
- NULL);
-
- FolderInfo *folderInfo = reinterpret_cast<FolderInfo *>(catalogInfo.finderInfo);
- return folderInfo->finderFlags & kHasBundle;
-}
-
-#else
-static inline bool _q_isMacHidden(const char *nativePath)
-{
- Q_UNUSED(nativePath);
- // no-op
- return false;
-}
-#endif
-
bool QFileSystemEngine::isCaseSensitive()
{
return true;
if (what & QFileSystemMetaData::HiddenAttribute
&& !data.isHidden()) {
QString fileName = entry.fileName();
- if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
- || (entryExists && _q_isMacHidden(nativeFilePath)))
+ if (fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
data.entryFlags |= QFileSystemMetaData::HiddenAttribute;
data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
}
#ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack
template <typename T>
-inline T *v_cast(const QVariant::Private *nd, T * = 0)
+inline T *v_cast(const QVariant::Private *nd, T * = Q_NULLPTR)
{
QVariant::Private *d = const_cast<QVariant::Private *>(nd);
return ((sizeof(T) > sizeof(QVariant::Private::Data))
#else // every other compiler in this world
template <typename T>
-inline const T *v_cast(const QVariant::Private *d, T * = 0)
+inline const T *v_cast(const QVariant::Private *d, T * = Q_NULLPTR)
{
return ((sizeof(T) > sizeof(QVariant::Private::Data))
? static_cast<const T *>(d->data.shared->ptr)
}
template <typename T>
-inline T *v_cast(QVariant::Private *d, T * = 0)
+inline T *v_cast(QVariant::Private *d, T * = Q_NULLPTR)
{
return ((sizeof(T) > sizeof(QVariant::Private::Data))
? static_cast<T *>(d->data.shared->ptr)
// constructs a new variant if copy is 0, otherwise copy-constructs
template <class T>
-inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
+inline void v_construct(QVariant::Private *x, const void *copy, T * = Q_NULLPTR)
{
if (sizeof(T) > sizeof(QVariant::Private::Data)) {
x->data.shared = copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T *>(copy))
// deletes the internal structures
template <class T>
-inline void v_clear(QVariant::Private *d, T* = 0)
+inline void v_clear(QVariant::Private *d, T* = Q_NULLPTR)
{
-
if (sizeof(T) > sizeof(QVariant::Private::Data)) {
//now we need to cast
//because QVariant::PrivateShared doesn't have a virtual destructor