[o2on-svn] [60] 複数datフォルダ機能追加 (O2DatIO)

Back to archive index

o2on svn commit o2on-****@lists*****
2008年 3月 18日 (火) 01:12:30 JST


Revision: 60
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=o2on&view=rev&rev=60
Author:   k-uehara
Date:     2008-03-18 01:12:29 +0900 (Tue, 18 Mar 2008)

Log Message:
-----------
複数datフォルダ機能追加(O2DatIO)

Modified Paths:
--------------
    trunk/o2on/src.o2on/O2DatIO.cpp

Modified: trunk/o2on/src.o2on/O2DatIO.cpp
===================================================================
--- trunk/o2on/src.o2on/O2DatIO.cpp	2008-03-17 10:53:24 UTC (rev 59)
+++ trunk/o2on/src.o2on/O2DatIO.cpp	2008-03-17 16:12:29 UTC (rev 60)
@@ -246,8 +246,20 @@
 O2DatIO::
 GetTitle(O2DatPath &datpath)
 {
-	wstring path;
+	wstrarray paths;
+	wstring path, cachef;
+	
 	datpath.getpath(Profile->GetCacheRootW(), path);
+	if (_waccess(path.c_str(), 0) != 0)
+	{
+		paths = *Profile->GetCacheFoldersW();
+		for (wstrarray::iterator it = paths.begin();it != paths.end(); it++)
+		{
+			datpath.getpath((*it).c_str(), path);
+			if (_waccess(path.c_str(), 0) == 0)
+				break;
+		}
+	}
 
 	MappedFile mf;
 	char *p = (char*)mf.open(path.c_str(), mf.allocG(), false);
@@ -317,9 +329,21 @@
 GetSize(const O2DatPath &datpath)
 {
 	string path;
+	struct _stat st;
+	strarray paths;
+	strarray::iterator it;
+	
+	paths = *Profile->GetCacheFoldersA();
+	for (it = paths.begin();it != paths.end(); it++)
+	{
+		datpath.getpath((*it).c_str(), path);
+		if (_stat(path.c_str(), &st) != -1)
+			return (st.st_size);
+	}
+
 	datpath.getpath(Profile->GetCacheRootA(), path);
 
-	struct _stat st;
+
 	if (_stat(path.c_str(), &st) == -1)
 		return (0);
 
@@ -342,9 +366,19 @@
 	struct _stat64 st;
 	FILE *fp = NULL;
 
-	string path;
+	strarray paths;
+	string path, cachef;
 	datpath.getpath(Profile->GetCacheRootA(), path);
-
+	if (_access(path.c_str(), 0) != 0)
+	{
+		paths = *Profile->GetCacheFoldersA();
+		for (strarray::iterator it = paths.begin();it != paths.end(); it++)
+		{
+			datpath.getpath((*it).c_str(), path);
+			if (_access(path.c_str(), 0) == 0)
+				break;
+		}
+	}
 	if (_stat64(path.c_str(), &st) == -1)
 		goto cleanup;
 
@@ -403,24 +437,31 @@
 	O2DatPath datpath;
 	wstring path;
 	O2DatRec rec;
+	wstrarray paths(*Profile->GetCacheFoldersW());
+	paths.push_back(Profile->GetAdminRootW());
+	wstrarray::iterator arit;
+	bool deleted;
 
 	for (it = hashlist.begin(); it != hashlist.end(); it++) {
+		deleted = false;
 		if (!DatDB->select(rec, *it))
 			continue;
 
 		datpath.set(rec.domain.c_str(), rec.bbsname.c_str(), rec.datname.c_str());
-		datpath.getpath(Profile->GetCacheRootW(), path);
+		for (arit = paths.begin(); arit != paths.end(); arit++) {
+			datpath.getpath((*arit).c_str(), path);
 #if 1
-		DWORD attr = GetFileAttributesW(path.c_str());
-		if (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_READONLY)) {
-			attr ^= FILE_ATTRIBUTE_READONLY;
-			SetFileAttributesW(path.c_str(), attr);
+				DWORD attr = GetFileAttributesW(path.c_str());
+				if (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_READONLY)) {
+					attr ^= FILE_ATTRIBUTE_READONLY;
+					SetFileAttributesW(path.c_str(), attr);
+				}
+#endif
+			if (DeleteFile(path.c_str()))
+				deleted = true;
 		}
-#endif
-		if (!DeleteFile(path.c_str()))
-			continue;
-
-		DatDB->remove(*it);
+		if (deleted)
+			DatDB->remove(*it);
 	}
 
 	return true;
@@ -480,11 +521,18 @@
 		return (0);
 
 	string path;
+	strarray paths = *Profile->GetCacheFoldersA();
+	struct _stat64 st;
+	for (strarray::iterator it = paths.begin(); it != paths.end(); it++) {
+		datpath.getpath((*it).c_str(), path);
+		if (_stat64(path.c_str(), &st) == 0) 
+			goto found;
+	}
+
 	datpath.getpath(Profile->GetCacheRootA(), path);
 	if (!datpath.makedir(Profile->GetCacheRootA()))
 		return false;
-
-	struct _stat64 st;
+found:
 	//FILE *fp;
 	strmap::const_iterator it;
 	uint64 hokan_byte = 0;
@@ -837,9 +885,13 @@
 StaticRebuildDBThread(void *data)
 {
 	O2DatIO *me = (O2DatIO*)data;
+	wstrarray cache(*me->Profile->GetCacheFoldersW());
+	cache.push_back(me->Profile->GetCacheRootW());
 
 	CoInitialize(NULL);
-	me->RebuildDBThread(me->Profile->GetCacheRootW(), 0);
+	for (wstrarray::iterator it = cache.begin(); it != cache.end(); it++) {
+		me->RebuildDBThread((*it).c_str(), 0);
+	}
 	CoUninitialize();
 
 	CloseHandle(me->RebuildDBThreadHandle);
@@ -1006,7 +1058,7 @@
 O2DatIO::
 EnumDatThread(const wchar_t *dir)
 {
-	ProgressInfo->SetMessage(dir+wcslen(Profile->GetCacheRootW()));
+	ProgressInfo->SetMessage(dir);
 
 	wchar_t findpath[MAX_PATH];
 	swprintf_s(findpath, MAX_PATH, L"%s\\*.*", dir);
@@ -1015,8 +1067,8 @@
 	wsplit(dir+wcslen(Profile->GetCacheRootW()), L"\\", paths);
 
 	O2DatRec rec;
-	rec.domain = paths[0];
-	rec.bbsname = paths[1];
+	rec.domain = paths[paths.size() - 3];
+	rec.bbsname = paths[paths.size() - 2];
 
 	O2DatPath datpath;
 	wchar_t path[MAX_PATH];




o2on-svn メーリングリストの案内
Back to archive index