37 #if defined(NCBI_OS_UNIX)
39 #if defined(HAVE_READPASSPHRASE)
40 # include <readpassphrase.h>
42 #elif defined(NCBI_OS_MSWIN)
45 # error "Unsuported platform"
68 #if defined(NCBI_OS_UNIX)
71 #if defined(HAVE_READPASSPHRASE)
73 char password_buffer[1024];
74 char* raw_password =
readpassphrase(prompt.c_str(), password_buffer,
75 sizeof(password_buffer),
78 #elif defined(HAVE_GETPASSPHRASE)
80 char* raw_password = getpassphrase(prompt.c_str());
82 #elif defined(HAVE_GETPASS)
84 char* raw_password = getpass(prompt.c_str());
87 # error "Unsupported Unix platform; the getpass, getpassphrase, and readpassphrase functions are all absent"
93 "g_GetPasswordFromConsole(): error getting password");
94 password =
string(raw_password);
96 #elif defined(NCBI_OS_MSWIN)
99 for (
size_t index = 0; index < prompt.size(); ++index) {
100 _putch(prompt[index]);
106 if (ch ==
'\r' || ch ==
'\n')
110 "g_GetPasswordFromConsole(): keyboard interrupt");
112 if ( !password.empty() ) {
113 password.resize(password.size() - 1);
117 password.append(1, ch);
142 static const char* kDelim =
";";
144 static const char* kDelim =
":";
160 if ( !path.Get().empty() ) {
164 if ( !dir.Get().empty() ) {
165 dirs.push_back(dir.Get());
171 ITERATE (list<string>, dir, dirs) {
186 idf.push_back(pattern);
188 idf.erase(
remove(idf.begin(), idf.end(), pattern), idf.end());
200 pos = id_line.
find(
' ', pos + 5);
204 pos = id_line.
find(
' ', pos + 1);
212 end = id_line.
find(
' ', end + 1);
217 CTime builtin_timestamp(builtin_timestamp_str,
"Y-M-D h:m:sZ");
223 CTime file_timestamp;
225 return file_timestamp < builtin_timestamp;
Exception class for g_GetPasswordFromConsole.
@ eGetPassError
UNIX specific: error getting password.
@ eKeyboardInterrupt
WIN specific: Ctrl+C has been sent.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
static void DLIST_NAME() remove(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
EFollowLinks
Whether to follow symbolic links (also known as shortcuts or aliases)
@ eIgnoreLinks
Do not follow symbolic links.
@ eFollowLinks
Follow symbolic links.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
EType
Directory entry type.
static bool IsAbsolutePath(const string &path)
Check if a "path" is absolute for the current OS.
virtual bool Exists(void) const
Check the entry existence.
static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
Assemble a path from basic components.
void Reset(const string &path)
Reset path string.
static bool MatchesMask(const string &name, const string &mask, NStr::ECase use_case=NStr::eCase)
Match a "name" against a simple filename "mask".
EType GetType(EFollowLinks follow=eIgnoreLinks) const
Get a type of a directory entry.
bool GetTime(CTime *modification, CTime *last_access=0, CTime *creation=0) const
Get time stamp(s) of a directory entry.
const string & GetPath(void) const
Get entry path.
@ eLink
Symbolic link (UNIX only)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
size_type find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
NCBI_PARAM_DECL(string, NCBI, DataPath)
NCBI_PARAM_DEF_EX(string, NCBI, DataPath, "", 0, NCBI_DATA_PATH)
typedef NCBI_PARAM_TYPE(NCBI, DataPath) TNCBIDataPath
NCBI_PARAM_DEF(string, NCBI, Data, "")
string g_GetPasswordFromConsole(const string &prompt)
Get a password without echoing the user input.
string g_FindDataFile(const CTempString &name, CDirEntry::EType type)
Look for an NCBI application data file or directory of the given name and type; in general,...
bool g_IsDataFileOld(const CTempString &path, const CTempString &id_line)
Check whether the given file (a full path, as returned by g_FindDataFile) is older than a built-in ve...
void g_IgnoreDataFile(const string &pattern, bool do_ignore)
Ignore (or stop ignoring, depending on do_ignore) NCBI application data files matching the given patt...
static CSafeStatic< TIgnoreDataFiles > s_IgnoredDataFiles
vector< string > TIgnoreDataFiles