diff --git a/cs/libconsh/cg.cpp b/cs/libconsh/cg.cpp index ed9e7ff..972ad84 100644 --- a/cs/libconsh/cg.cpp +++ b/cs/libconsh/cg.cpp @@ -14,6 +14,7 @@ All rights reserved. #include "StdAfx.h" #include +#include #include "machine-min.h" // 03/08/00 AM. #include "prim/libprim.h" #include "lite/global.h" @@ -53,7 +54,6 @@ All rights reserved. #include "cmd.h" #include "dyn.h" // 06/29/00 AM. #include "lite/dir.h" -#include "lite/io.h" #include "prim/unicu.h" using namespace unicu; @@ -3489,18 +3489,16 @@ return word; CONCEPT *CG::matchDictKB(std::string dictFilename, std::vector kbfiles) { if (kbfiles.size() == 0) return NULL; std::vector::iterator ptr; - - _TCHAR buff[MAXSTR], buffkb[MAXSTR]; - _TCHAR *head, *headkb; + CONCEPT *con, *dictcon; - _tcscpy(buff, dictFilename.c_str()); - file_head(buff, head); + std::filesystem::path filePath(dictFilename); + std::string head = removeExtension(filePath.filename().string()); for (ptr = kbfiles.begin(); ptr < kbfiles.end(); ptr++) { - _tcscpy(buffkb, ptr->string().c_str()); - file_head(buff, headkb); + std::filesystem::path kbpath(ptr->string()); + std::string headkb = removeExtension(kbpath.filename().string()); - if (!_tcscmp(head,headkb)) { + if (std::strcmp(head.c_str(), headkb.c_str()) == 0) { con = findRoot(); dictcon = findConcept(con,"dictionary"); if (dictcon) { @@ -3511,6 +3509,13 @@ CONCEPT *CG::matchDictKB(std::string dictFilename, std::vector& files) { bool found = false; files.clear(); diff --git a/include/Api/consh/cg.h b/include/Api/consh/cg.h index d73137a..511650a 100644 --- a/include/Api/consh/cg.h +++ b/include/Api/consh/cg.h @@ -214,6 +214,7 @@ class LIBCONSH_API CG CONCEPT *findWordConcept(_TCHAR*); // 06/29/03 AM. CONCEPT *matchDictKB(std::string dictFilename, std::vector kbfiles); + std::string removeExtension(const std::string& filename); bool openDict(std::vector& files); bool readDicts(std::vector files, std::vector kbfiles); bool readDict(std::string file, std::vector kbfiles); diff --git a/include/Api/lite/io.h b/include/Api/lite/io.h deleted file mode 100644 index 97a0323..0000000 --- a/include/Api/lite/io.h +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* -Copyright (c) 2001-2010 by Text Analysis International, Inc. -All rights reserved. -******************************************************************************** -* -* NAME: IO.H -* FILE: lite\io.h -* CR: 10/06/98 AM. -* SUBJ: Declares for I/O functions. -* -*******************************************************************************/ - -//#include "fstream.h" - -void copy_file(const _TCHAR *, const _TCHAR *); -bool file_exists(const _TCHAR *iname); // 12/14/98 AM. -void file_to_buffer(const _TCHAR *, _TCHAR *, - /*UP*/ long &len // 05/28/00 /AM. - ); -_TCHAR *pretty_char(_TCHAR); -_TCHAR *pretty_str( - _TCHAR *str, // String to be prettified. - _TCHAR *buf, // Buffer for placing prettified string. - long size - ); -_TCHAR *c_char(_TCHAR,_TCHAR*); // 05/10/00 AM. -_TCHAR *c_str( // 05/10/00 AM. - _TCHAR *str, // String to be prettified. - _TCHAR *buf, // Buffer for placing prettified string. - long size // Buffer size. (-1 means count not used.) - ); - - -void read_file( - _TCHAR *fname, // The filename - /*UP*/ - long &len, // Length of file. - _TCHAR* &buf // Buffer to create. - ) - ; - -_TCHAR *next_token(/*DU*/ _TCHAR* &buf, bool &eol, _TCHAR *comment); - -bool fix_file_name( - _TCHAR *file, // Buffer big enough to hold extension. - _TCHAR *suff // File name extension needed. - ) - ; - -bool eq_str_range(_TCHAR *str, _TCHAR *ptr, long start, long end); - -_TCHAR *make_str(_TCHAR *str); -_TCHAR *make_str(_TCHAR *str, long len); - -bool strcat_e( - /*DU*/ _TCHAR* &ptr, - /*DN*/ _TCHAR *str, - /*DU*/ long &count - ); - - -bool strncat_e( - /*DU*/ _TCHAR* &ptr, - /*DN*/ _TCHAR *str, - /*DN*/ long len, - /*DU*/ long &count - ); - - -bool file_name( // 12/24/99 AM. - _TCHAR *file, // Buffer with full file string. - /*UP*/ - _TCHAR* &fname // Pointer to the name in buffer. - ); -bool file_path( // 12/24/99 AM. - _TCHAR *file, // Buffer with full file string. - /*UP*/ - _TCHAR* &fpath // Pointer to the path in buffer. - ); -bool file_parent( - _TCHAR *file, // Buffer with full file string. - /*UP*/ - _TCHAR* &fpath // Pointer to the path in buffer. - ); -bool file_head( // 12/24/99 AM. - _TCHAR *file, // Buffer with full file string. - /*UP*/ - _TCHAR* &fhead // Pointer to the file head in buffer. - ); -bool file_tail( // 12/24/99 AM. - _TCHAR *file, // Buffer with full file string. - /*UP*/ - _TCHAR* &ftail // Pointer to tail in buffer. - );