Placement of user splell_check directories fixed
* User collected dictionaries and indexes are moved under ~/config/data/spell_check/ folder. Fixes #7887. * This fix was made during completing GCI 2011 task. Signed-off-by: Siarzhuk Zharski <[email protected]>
This commit is contained in:
committed by
Siarzhuk Zharski
parent
975f024407
commit
1516a674a2
+42
-15
@@ -464,23 +464,37 @@ TMailApp::ReadyToRun()
|
|||||||
// Load dictionaries
|
// Load dictionaries
|
||||||
BPath indexDir;
|
BPath indexDir;
|
||||||
BPath dictionaryDir;
|
BPath dictionaryDir;
|
||||||
|
BPath userDictionaryDir;
|
||||||
|
BPath userIndexDir;
|
||||||
BPath dataPath;
|
BPath dataPath;
|
||||||
BPath indexPath;
|
BPath indexPath;
|
||||||
BDirectory directory;
|
BDirectory directory;
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
|
||||||
// Locate user settings directory
|
// Locate dictionaries directory
|
||||||
find_directory(B_SYSTEM_DATA_DIRECTORY, &indexDir, true);
|
find_directory(B_SYSTEM_DATA_DIRECTORY, &indexDir, true);
|
||||||
indexDir.Append("spell_check");
|
indexDir.Append("spell_check");
|
||||||
dictionaryDir = indexDir;
|
dictionaryDir = indexDir;
|
||||||
|
|
||||||
|
//Locate user dictionary directory
|
||||||
|
find_directory(B_USER_CONFIG_DIRECTORY, &userIndexDir, true);
|
||||||
|
userIndexDir.Append("data/spell_check");
|
||||||
|
userDictionaryDir = userIndexDir;
|
||||||
|
|
||||||
|
// Create directory if needed
|
||||||
|
directory.CreateDirectory(userIndexDir.Path(), NULL);
|
||||||
|
|
||||||
// Setup directory paths
|
// Setup directory paths
|
||||||
indexDir.Append(kIndexDirectory);
|
indexDir.Append(kIndexDirectory);
|
||||||
dictionaryDir.Append(kDictDirectory);
|
dictionaryDir.Append(kDictDirectory);
|
||||||
|
userIndexDir.Append(kIndexDirectory);
|
||||||
|
userDictionaryDir.Append(kDictDirectory);
|
||||||
|
|
||||||
// Create directories if needed
|
// Create directories if needed
|
||||||
directory.CreateDirectory(indexDir.Path(), NULL);
|
directory.CreateDirectory(indexDir.Path(), NULL);
|
||||||
directory.CreateDirectory(dictionaryDir.Path(), NULL);
|
directory.CreateDirectory(dictionaryDir.Path(), NULL);
|
||||||
|
directory.CreateDirectory(userIndexDir.Path(), NULL);
|
||||||
|
directory.CreateDirectory(userDictionaryDir.Path(), NULL);
|
||||||
|
|
||||||
dataPath = dictionaryDir;
|
dataPath = dictionaryDir;
|
||||||
dataPath.Append("words");
|
dataPath.Append("words");
|
||||||
@@ -500,14 +514,6 @@ TMailApp::ReadyToRun()
|
|||||||
BNodeInfo(©).SetType("text/plain");
|
BNodeInfo(©).SetType("text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create user dictionary if it does not exist
|
|
||||||
dataPath = dictionaryDir;
|
|
||||||
dataPath.Append("user");
|
|
||||||
if (!BEntry(dataPath.Path()).Exists()) {
|
|
||||||
BFile user(dataPath.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
|
||||||
BNodeInfo(&user).SetType("text/plain");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load dictionaries
|
// Load dictionaries
|
||||||
directory.SetTo(dictionaryDir.Path());
|
directory.SetTo(dictionaryDir.Path());
|
||||||
|
|
||||||
@@ -518,12 +524,6 @@ TMailApp::ReadyToRun()
|
|||||||
&& directory.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
|
&& directory.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
|
||||||
dataPath.SetTo(&entry);
|
dataPath.SetTo(&entry);
|
||||||
|
|
||||||
// Identify the user dictionary
|
|
||||||
if (strcmp("user", dataPath.Leaf()) == 0) {
|
|
||||||
gUserDictFile = new BFile(dataPath.Path(), B_WRITE_ONLY | B_OPEN_AT_END);
|
|
||||||
gUserDict = gDictCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
indexPath = indexDir;
|
indexPath = indexDir;
|
||||||
leafName.SetTo(dataPath.Leaf());
|
leafName.SetTo(dataPath.Leaf());
|
||||||
leafName.Append(kMetaphone);
|
leafName.Append(kMetaphone);
|
||||||
@@ -536,6 +536,33 @@ TMailApp::ReadyToRun()
|
|||||||
indexPath.Append(leafName.String());
|
indexPath.Append(leafName.String());
|
||||||
gExactWords[gDictCount] = new Words(dataPath.Path(), indexPath.Path(), false);
|
gExactWords[gDictCount] = new Words(dataPath.Path(), indexPath.Path(), false);
|
||||||
gDictCount++;
|
gDictCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create user dictionary if it does not exist
|
||||||
|
dataPath = userDictionaryDir;
|
||||||
|
dataPath.Append("user");
|
||||||
|
if (!BEntry(dataPath.Path()).Exists()) {
|
||||||
|
BFile user(dataPath.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
||||||
|
BNodeInfo(&user).SetType("text/plain");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load user dictionary
|
||||||
|
if (BEntry(userDictionaryDir.Path()).Exists()) {
|
||||||
|
gUserDictFile = new BFile(dataPath.Path(), B_WRITE_ONLY | B_OPEN_AT_END);
|
||||||
|
gUserDict = gDictCount;
|
||||||
|
|
||||||
|
indexPath = userIndexDir;
|
||||||
|
leafName.SetTo(dataPath.Leaf());
|
||||||
|
leafName.Append(kMetaphone);
|
||||||
|
indexPath.Append(leafName.String());
|
||||||
|
gWords[gDictCount] = new Words(dataPath.Path(), indexPath.Path(), true);
|
||||||
|
|
||||||
|
indexPath = userIndexDir;
|
||||||
|
leafName.SetTo(dataPath.Leaf());
|
||||||
|
leafName.Append(kExact);
|
||||||
|
indexPath.Append(leafName.String());
|
||||||
|
gExactWords[gDictCount] = new Words(dataPath.Path(), indexPath.Path(), false);
|
||||||
|
gDictCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user