Skip to content

Commit

Permalink
Change default directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancorvussolis committed May 14, 2016
1 parent 529b6fa commit cbf5995
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 31 deletions.
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,22 @@ IME ON/OFF のキーのみ、IME ON → OFF のときにも反映されます。

取込済SKK辞書の skkdict.txt ファイルは、UTF-16 (LE, BOMあり) のSKK辞書フォーマットとなっています。

ディレクトリ %AppData%\CorvusSKK にファイルが存在しないときは %SystemRoot%\IME\IMCRVSKK にインストールされているファイルが使用されます。

SKK辞書サーバーを使用するなどでローカルのSKK辞書を使用したくないときは、設定ダイアログのSKK辞書のリストが空またはチェック無しの状態で取込処理をおこなってください。空の取込済SKK辞書が生成されます。

下記のディレクトリの優先順位で各ファイルが読み込まれます。

1. %AppData%\CorvusSKK
2. %SystemRoot%\IME\IMCRVSKK (インストーラーによりインストール済み)

> **開発者向け**
>
> デバッグビルドでは、ディレクトリ %AppData%\CorvusSKK_DEBUG の各ファイルに保存されます。
>
> デバッグビルドでは、下記のディレクトリの優先順位で各ファイルが読み込まれます。
>
> 1. %AppData%\CorvusSKK_DEBUG
> 2. 実行ファイルと同じディレクトリ (ビルドするとディレクトリ installer\config-share から上書きコピーされます)

### ユーザー辞書

Expand Down Expand Up @@ -460,14 +472,23 @@ Lua内部の文字コードをUTF-8に決め打ちして、Unicode版のWindowsA

スクリプトファイルの文字コードはUTF-8のみに対応しています。

辞書管理プロセスのカレントディレクトリは%AppData%\CorvusSKK になっています。
辞書管理プロセスのカレントディレクトリは %AppData%\CorvusSKK になっています。

辞書管理プロセスの起動時にスクリプトファイル (init.lua) が下記の優先順位でロードされます。
コンソールプログラムのlua.exeが %SystemRoot%\System32\IME\IMCRVSKK と %SystemRoot%\SysWOW64\IME\IMCRVSKK にあるので、カスタマイズする際のデバッグ用に使ってください。

辞書管理プロセスの起動時にスクリプトファイル (init.lua) が下記の優先順位で読み込まれます。

1. %AppData%\CorvusSKK\init.lua
2. %SystemRoot%\IME\IMCRVSKK\init.lua (インストーラーによりインストール済み)

コンソールプログラムのlua.exeが %SystemRoot%\System32\IME\IMCRVSKK と %SystemRoot%\SysWOW64\IME\IMCRVSKK にあるので、カスタマイズする際のデバッグ用に使ってください。
> **開発者向け**
>
> デバッグビルドでは、辞書管理プロセスのカレントディレクトリは %AppData%\CorvusSKK_DEBUG になっています。
>
> デバッグビルドでは、下記の優先順位でスクリプトファイルが読み込まれます。
>
> 1. %AppData%\CorvusSKK_DEBUG\init.lua
> 2. 実行ファイルと同じディレクトリのinit.lua (ビルドするとディレクトリ installer\config-lua から上書きコピーされます)

### プログラム実行変換もどき
Expand Down
45 changes: 39 additions & 6 deletions imcrvmgr/ConfigMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ void UpdateConfigPath()
{
PWSTR knownfolderpath = nullptr;

//%AppData%\\CorvusSKK\\config.xml
//%AppData%\\CorvusSKK\\skkdict.txt
if(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath) == S_OK)
{
_snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnconfigxml);
Expand All @@ -94,21 +96,52 @@ void UpdateConfigPath()
CoTaskMemFree(knownfolderpath);
}

if(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath) == S_OK)
if(GetFileAttributesW(pathconfigxml) == INVALID_FILE_ATTRIBUTES)
{
#ifdef _DEBUG
//<module directory>\\config.xml
if(GetModuleFileNameW(hInst, pathconfigxml, _countof(pathconfigxml)) != 0)
{
WCHAR *pdir = wcsrchr(pathconfigxml, L'\\');
if(pdir != nullptr)
{
*(pdir + 1) = L'\0';
wcsncat_s(pathconfigxml, fnconfigxml, _TRUNCATE);
}
}
#else
//%SystemRoot%\\IME\\IMCRVSKK\\config.xml
if(GetFileAttributesW(pathconfigxml) == INVALID_FILE_ATTRIBUTES)
if(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath) == S_OK)
{
_snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fnconfigxml);

CoTaskMemFree(knownfolderpath);
}
#endif
}

if(GetFileAttributesW(pathskkdic) == INVALID_FILE_ATTRIBUTES)
{
#ifdef _DEBUG
//<module directory>\\skkdict.txt
if(GetModuleFileNameW(hInst, pathskkdic, _countof(pathskkdic)) != 0)
{
WCHAR *pdir = wcsrchr(pathskkdic, L'\\');
if(pdir != nullptr)
{
*(pdir + 1) = L'\0';
wcsncat_s(pathskkdic, fnskkdic, _TRUNCATE);
}
}
#else
//%SystemRoot%\\IME\\IMCRVSKK\\skkdict.txt
if(GetFileAttributesW(pathskkdic) == INVALID_FILE_ATTRIBUTES)
if(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath) == S_OK)
{
_snwprintf_s(pathskkdic, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fnskkdic);
}

CoTaskMemFree(knownfolderpath);
CoTaskMemFree(knownfolderpath);
}
#endif
}
}

Expand Down Expand Up @@ -206,7 +239,7 @@ void LoadConfig()
}
}

BOOL IsFileUpdated(LPCWSTR path, FILETIME *ft)
BOOL IsFileModified(LPCWSTR path, FILETIME *ft)
{
BOOL ret = FALSE;
HANDLE hFile;
Expand Down
4 changes: 2 additions & 2 deletions imcrvmgr/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ unsigned int __stdcall SrvThread(void *p)

UpdateConfigPath();

if(IsFileUpdated(pathconfigxml, &ftConfig))
if(IsFileModified(pathconfigxml, &ftConfig))
{
LoadConfig();
}

if(IsFileUpdated(pathskkdic, &ftSKKDic))
if(IsFileModified(pathskkdic, &ftSKKDic))
{
MakeSKKDicPos();
}
Expand Down
4 changes: 2 additions & 2 deletions imcrvmgr/imcrvmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
WSAStartup(WINSOCK_VERSION, &wsaData);

ZeroMemory(&ftConfig, sizeof(ftConfig));
if(IsFileUpdated(pathconfigxml, &ftConfig))
if(IsFileModified(pathconfigxml, &ftConfig))
{
LoadConfig();
}

ZeroMemory(&ftSKKDic, sizeof(ftSKKDic));
if(IsFileUpdated(pathskkdic, &ftSKKDic))
if(IsFileModified(pathskkdic, &ftSKKDic))
{
MakeSKKDicPos();
}
Expand Down
2 changes: 1 addition & 1 deletion imcrvmgr/imcrvmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void CreateConfigPath();
void UpdateConfigPath();
void CreateIpcName();
void LoadConfig();
BOOL IsFileUpdated(LPCWSTR path, FILETIME *ft);
BOOL IsFileModified(LPCWSTR path, FILETIME *ft);
void InitLua();
void UninitLua();

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion installer/_build_x86.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pushd "%~dp0"

call _version.cmd

call _build_x86_sub.cmd
call _build_sub.cmd

"%WIX%bin\candle.exe" installer-x86.wxs -nologo -out "%TARGETDIR%\x86.wixobj"
"%WIX%bin\light.exe" "%TARGETDIR%\x86.wixobj" -nologo -out "%TARGETDIR%\x86.msi" -ext WixUIExtension -sw1076
Expand Down
16 changes: 16 additions & 0 deletions installer/_clean_sub.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off
setlocal

pushd "%~dp0"

call _version.cmd

if exist "%TARGETDIR%\README.html" del "%TARGETDIR%\README.html"
if exist "%TARGETDIR%\LICENSE.txt" del "%TARGETDIR%\LICENSE.txt"
if exist "%TARGETDIR%\config.xml" del "%TARGETDIR%\config.xml"
if exist "%TARGETDIR%\init.lua" del "%TARGETDIR%\init.lua"
if exist "%TARGETDIR%\skkdict.txt" del "%TARGETDIR%\skkdict.txt"

popd

endlocal
7 changes: 2 additions & 5 deletions installer/_clean_x86.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ pushd "%~dp0"
call _version.cmd

if exist "%TARGETDIR%\x86.*" del "%TARGETDIR%\x86.*"
if exist "%TARGETDIR%\README.html" del "%TARGETDIR%\README.html"
if exist "%TARGETDIR%\LICENSE.txt" del "%TARGETDIR%\LICENSE.txt"
if exist "%TARGETDIR%\config.xml" del "%TARGETDIR%\config.xml"
if exist "%TARGETDIR%\init.lua" del "%TARGETDIR%\init.lua"
if exist "%TARGETDIR%\skkdict.txt" del "%TARGETDIR%\skkdict.txt"

call _clean_sub.cmd

popd

Expand Down
27 changes: 20 additions & 7 deletions installer/installer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
<None Include="_build_x64.cmd" />
<None Include="_build_x86.cmd" />
<None Include="_clean.cmd" />
<None Include="_clean_sub.cmd" />
<None Include="_clean_x64.cmd" />
<None Include="_clean_x86.cmd" />
<None Include="_debug_reg.cmd" />
<None Include="_debug_unreg.cmd" />
<None Include="_build_x86_sub.cmd" />
<None Include="_build_sub.cmd" />
<None Include="_sign.cmd" />
<None Include="_solution_build.cmd" />
<None Include="_solution_clean.cmd" />
Expand Down Expand Up @@ -136,22 +137,34 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeBuildCommandLine>copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul</NMakeBuildCommandLine>
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
</NMakeBuildCommandLine>
<NMakeCleanCommandLine>del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" &gt; nul
del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" &gt; nul</NMakeCleanCommandLine>
del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" &gt; nul
del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" &gt; nul
</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul</NMakeReBuildCommandLine>
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>build\</OutDir>
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul</NMakeBuildCommandLine>
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
</NMakeBuildCommandLine>
<NMakeCleanCommandLine>del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" &gt; nul
del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" &gt; nul</NMakeCleanCommandLine>
del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" &gt; nul
del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" &gt; nul
</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul</NMakeReBuildCommandLine>
copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" &gt; nul
</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>build\</OutDir>
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
Expand Down
7 changes: 5 additions & 2 deletions installer/installer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
<None Include="_build_bundle.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_build_sub.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_build_x64.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_build_x86.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_build_x86_sub.cmd">
<None Include="_clean.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_clean.cmd">
<None Include="_clean_sub.cmd">
<Filter>Installer Files</Filter>
</None>
<None Include="_clean_x64.cmd">
Expand Down

0 comments on commit cbf5995

Please sign in to comment.