mirror of
https://github.com/BlueMatthew/WechatExporter.git
synced 2026-08-30 00:50:33 +08:00
Optmize code for debugging
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
||||
@@ -31,6 +31,15 @@ public:
|
||||
return existed == YES && isDir == YES;
|
||||
}
|
||||
|
||||
bool existsFile(const std::string& path) const
|
||||
{
|
||||
BOOL isDir = NO;
|
||||
NSString *ocPath = [NSString stringWithUTF8String: path.c_str()];
|
||||
|
||||
BOOL existed = [[NSFileManager defaultManager] fileExistsAtPath:ocPath isDirectory:&isDir];
|
||||
return existed == YES;
|
||||
}
|
||||
|
||||
bool listSubDirectories(const std::string& path, std::vector<std::string>& subDirectories) const
|
||||
{
|
||||
struct dirent *entry;
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
|
||||
virtual bool existsDirectory(const std::string& path) const = 0;
|
||||
virtual bool makeDirectory(const std::string& path) const = 0;
|
||||
virtual bool existsFile(const std::string& path) const = 0;
|
||||
virtual bool listSubDirectories(const std::string& path, std::vector<std::string>& subDirectories) const = 0;
|
||||
virtual bool copyFile(const std::string& src, const std::string& dest, bool overwrite) const = 0;
|
||||
virtual bool openOutputFile(std::ofstream& ofs, const std::string& fileName, std::ios_base::openmode mode = std::ios::out) const = 0;
|
||||
|
||||
@@ -861,8 +861,8 @@ bool SessionParser::parseRow(Record& record, const std::string& userBase, const
|
||||
}
|
||||
else if (record.type == 62 || record.type == 43)
|
||||
{
|
||||
bool hasthum = requireResource(combinePath(userBase, "Video", session.Hash, msgIdStr + ".video_thum"), combinePath(assetsDir, msgIdStr + "_thum.jpg"));
|
||||
bool hasvid = requireResource(combinePath(userBase, "Video", session.Hash, msgIdStr + ".mp4"), combinePath(assetsDir, msgIdStr + ".mp4"));
|
||||
bool hasthum = requireFile(combinePath(userBase, "Video", session.Hash, msgIdStr + ".video_thum"), combinePath(assetsDir, msgIdStr + "_thum.jpg"));
|
||||
bool hasvid = requireFile(combinePath(userBase, "Video", session.Hash, msgIdStr + ".mp4"), combinePath(assetsDir, msgIdStr + ".mp4"));
|
||||
|
||||
std::string msgFile;
|
||||
if (hasthum || hasvid)
|
||||
@@ -908,8 +908,8 @@ bool SessionParser::parseRow(Record& record, const std::string& userBase, const
|
||||
{
|
||||
std::string vfile = combinePath(userBase, "Img", session.Hash, msgIdStr);
|
||||
|
||||
bool hasthum = requireResource(vfile + ".pic_thum", combinePath(assetsDir, msgIdStr + "_thum.jpg"));
|
||||
bool haspic = requireResource(vfile + ".pic", combinePath(assetsDir, msgIdStr + ".jpg"));
|
||||
bool hasthum = requireFile(vfile + ".pic_thum", combinePath(assetsDir, msgIdStr + "_thum.jpg"));
|
||||
bool haspic = requireFile(vfile + ".pic", combinePath(assetsDir, msgIdStr + ".jpg"));
|
||||
|
||||
std::string msgFile;
|
||||
if (hasthum || haspic)
|
||||
@@ -1053,11 +1053,18 @@ std::string SessionParser::getLocaleString(const std::string& key) const
|
||||
return it == m_localeStrings.cend() ? key : it->second;
|
||||
}
|
||||
|
||||
bool SessionParser::requireResource(const std::string& vpath, const std::string& dest) const
|
||||
bool SessionParser::requireFile(const std::string& vpath, const std::string& dest) const
|
||||
{
|
||||
std::string srcPath = m_iTunesDb.findRealPath(vpath);
|
||||
if (!srcPath.empty())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// Make debug more effective
|
||||
if (m_shell.existsFile(srcPath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return m_shell.copyFile(srcPath, dest, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
std::string getTemplate(const std::string& key) const;
|
||||
std::string getLocaleString(const std::string& key) const;
|
||||
std::string getDisplayTime(int ms) const;
|
||||
bool requireResource(const std::string& vpath, const std::string& dest) const;
|
||||
bool requireFile(const std::string& vpath, const std::string& dest) const;
|
||||
bool parseRow(Record& record, const std::string& userBase, const std::string& path, const Session& session, std::string& templateKey, std::map<std::string, std::string>& templateValues) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,16 @@ public:
|
||||
return ::SHCreateDirectoryEx(NULL, (LPCTSTR)pszT, NULL) == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
bool existsFile(const std::string& path) const
|
||||
{
|
||||
CW2T pszT(CA2W(path.c_str(), CP_UTF8));
|
||||
|
||||
DWORD dwAttrib = ::GetFileAttributes((LPCTSTR)pszT);
|
||||
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
|
||||
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
|
||||
bool listSubDirectories(const std::string& path, std::vector<std::string>& subDirectories) const
|
||||
{
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
|
||||
Reference in New Issue
Block a user