void ArcAPI::find_sfx_modules(const wstring& path) { FileEnum file_enum(path); wstring dir = extract_file_path(path); bool more; while (file_enum.next_nt(more) && more) { SfxModule sfx_module; sfx_module.path = add_trailing_slash(dir) + file_enum.data().cFileName; File file; if (!file.open_nt(sfx_module.path, FILE_READ_DATA, FILE_SHARE_READ, OPEN_EXISTING, 0)) continue; Buffer<char> buffer(2); unsigned sz; if (!file.read_nt(buffer.data(), static_cast<unsigned>(buffer.size()), sz)) continue; string sig(buffer.data(), sz); if (sig != "MZ") continue; sfx_modules.push_back(sfx_module); } }
list<wstring> get_include_file_list(const wstring& file_path, const list<wstring>& include_dirs) { list<wstring> file_list; wstring text = load_file(file_path); wstring inc_file; size_t pos = 0; while (true) { if (is_include_directive(text, pos, inc_file)) { fix_slashes(inc_file); wstring inc_path = add_trailing_slash(extract_file_path(file_path)) + inc_file; bool found = file_exists(inc_path); for (list<wstring>::const_iterator inc_dir = include_dirs.begin(); !found && inc_dir != include_dirs.end(); inc_dir++) { inc_path = add_trailing_slash(*inc_dir) + inc_file; found = file_exists(inc_path); } if (found) file_list.push_back(inc_path); } pos = text.find(L'\n', pos); if (pos == wstring::npos) break; else pos++; } return file_list; }
void ArcAPI::load_libs(const wstring& path) { FileEnum file_enum(path); wstring dir = extract_file_path(path); bool more; while (file_enum.next_nt(more) && more) { ArcLib arc_lib; arc_lib.module_path = add_trailing_slash(dir) + file_enum.data().cFileName; arc_lib.h_module = LoadLibraryW(arc_lib.module_path.c_str()); if (arc_lib.h_module == nullptr) continue; arc_lib.CreateObject = reinterpret_cast<ArcLib::FCreateObject>(GetProcAddress(arc_lib.h_module, "CreateObject")); arc_lib.GetNumberOfMethods = reinterpret_cast<ArcLib::FGetNumberOfMethods>(GetProcAddress(arc_lib.h_module, "GetNumberOfMethods")); arc_lib.GetMethodProperty = reinterpret_cast<ArcLib::FGetMethodProperty>(GetProcAddress(arc_lib.h_module, "GetMethodProperty")); arc_lib.GetNumberOfFormats = reinterpret_cast<ArcLib::FGetNumberOfFormats>(GetProcAddress(arc_lib.h_module, "GetNumberOfFormats")); arc_lib.GetHandlerProperty = reinterpret_cast<ArcLib::FGetHandlerProperty>(GetProcAddress(arc_lib.h_module, "GetHandlerProperty")); arc_lib.GetHandlerProperty2 = reinterpret_cast<ArcLib::FGetHandlerProperty2>(GetProcAddress(arc_lib.h_module, "GetHandlerProperty2")); if (arc_lib.CreateObject && ((arc_lib.GetNumberOfFormats && arc_lib.GetHandlerProperty2) || arc_lib.GetHandlerProperty)) { arc_lib.version = get_module_version(arc_lib.module_path); arc_libs.push_back(arc_lib); } else FreeLibrary(arc_lib.h_module); } }
wstring get_plugin_module_path() { return extract_file_path(g_far.ModuleName); }
wstring arc_dir() const { return extract_file_path(arc_path); }