static CFX_WideString FILESPEC_DecodeFileName(const CFX_WideStringC& filepath) { if (filepath.GetLength() <= 1) { return CFX_WideString(); } #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) { return ChangeSlashToPlatform(filepath.GetPtr() + 1); } return ChangeSlashToPlatform(filepath.GetPtr()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (filepath.GetAt(0) != '/') { return ChangeSlashToPlatform(filepath.GetPtr()); } if (filepath.GetAt(1) == '/') { return ChangeSlashToPlatform(filepath.GetPtr() + 1); } if (filepath.GetAt(2) == '/') { CFX_WideString result; result += filepath.GetAt(1); result += ':'; result += ChangeSlashToPlatform(filepath.GetPtr() + 2); return result; } CFX_WideString result; result += '\\'; result += ChangeSlashToPlatform(filepath.GetPtr()); return result; #else return filepath; #endif }
CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) { if (filepath.GetLength() <= 1) return CFX_WideString(); #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) return ChangeSlashToPlatform(filepath.c_str() + 1); return ChangeSlashToPlatform(filepath.c_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (filepath.GetAt(0) != '/') return ChangeSlashToPlatform(filepath.c_str()); if (filepath.GetAt(1) == '/') return ChangeSlashToPlatform(filepath.c_str() + 1); if (filepath.GetAt(2) == '/') { CFX_WideString result; result += filepath.GetAt(1); result += ':'; result += ChangeSlashToPlatform(filepath.c_str() + 2); return result; } CFX_WideString result; result += '\\'; result += ChangeSlashToPlatform(filepath.c_str()); return result; #else return CFX_WideString(filepath); #endif }
CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath) { if (filepath.GetLength() <= 1) { return CFX_WideString(); } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (filepath.GetAt(1) == ':') { CFX_WideString result; result = '/'; result += filepath.GetAt(0); if (filepath.GetAt(2) != '\\') { result += '/'; } result += ChangeSlashToPDF(filepath.GetPtr() + 2); return result; } if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\') { return ChangeSlashToPDF(filepath.GetPtr() + 1); } if (filepath.GetAt(0) == '\\') { CFX_WideString result; result = '/'; result += ChangeSlashToPDF(filepath.GetPtr()); return result; } return ChangeSlashToPDF(filepath.GetPtr()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (filepath.Left(sizeof("Mac") - 1) == FX_WSTRC(L"Mac")) { CFX_WideString result; result = '/'; result += ChangeSlashToPDF(filepath.GetPtr()); return result; } return ChangeSlashToPDF(filepath.GetPtr()); #else return filepath; #endif }