42 #define NCBI_USE_ERRCODE_X Serial_Util
49 : m_StreamPtr(0), m_Open(
false)
51 if ( name ==
"stdin" || name ==
"-" ) {
55 if ( !
x_Open(name, binary) )
63 if ( name ==
"stdin" || name ==
"-" ) {
65 }
else if ( !
x_Open(name, binary) ) {
66 ITERATE(list<string>, dir, dirs) {
88 string ext(entry.
GetExt());
123 if ( name ==
"stdout" || name ==
"-" ) {
149 #undef DIR_SEPARATOR_CHAR
150 #undef DIR_SEPARATOR_CHAR2
151 #undef DISK_SEPARATOR_CHAR
152 #undef ALL_SEPARATOR_CHARS
153 #define PARENT_DIR ".."
156 # define DIR_SEPARATOR_CHAR '\\'
157 # define DIR_SEPARATOR_CHAR2 '/'
158 # define DISK_SEPARATOR_CHAR ':'
159 # define ALL_SEPARATOR_CHARS ":/\\"
162 #ifndef DIR_SEPARATOR_CHAR
163 # define DIR_SEPARATOR_CHAR '/'
166 #ifndef ALL_SEPARATOR_CHARS
167 # define ALL_SEPARATOR_CHARS DIR_SEPARATOR_CHAR
170 #ifdef DISK_SEPARATOR_CHAR
187 #ifdef DISK_SEPARATOR_CHAR
191 #ifdef DIR_SEPARATOR_CHAR2
226 #ifdef DISK_SEPARATOR_CHAR
247 char lastChar = dir[dir.size() - 1];
249 _TRACE(
"Path(\"" << dir <<
"\", \"" <<
file <<
"\")");
253 return dir.substr(0, dir.size()-1) +
file;
266 if ( dirEnd !=
NPOS )
267 name = path.substr(dirEnd + 1);
271 if ( extStart !=
NPOS )
272 name = name.substr(0, extStart);
279 if ( dirEnd !=
NPOS ) {
284 return path.substr(0, dirEnd);
293 string stdpath = path;
343 size_t fullLength = name.size() + addLength;
349 _TRACE(
"MakeFileName(\""<<fname<<
"\", "<<addLength<<
") remove="<<
remove);
363 _TRACE(
"MakeFileName: \""<<name.substr(curr, und - curr)<<
"\"");
364 removable += (und - curr);
365 byLength.insert(
SSubString(name.substr(curr, und - curr), order));
369 _TRACE(
"MakeFileName: \""<<name.substr(curr)<<
"\"");
370 removable += name.size() - curr;
371 byLength.insert(
SSubString(name.substr(curr), order));
373 _TRACE(
"MakeFileName: removable="<<removable);
387 byLength.erase(byLength.begin());
399 ITERATE ( TByLength,
i, byLength ) {
412 _TRACE(
"MakeFileName: return \""<<name<<
"\"");
430 seekp(0, IOS_BASE::beg);
465 size_t count = s.size();
466 const char* ptr = s.data();
467 while (
count > 0 ) {
474 " need: " << c <<
" was: " <<
m_Istream->gcount());
477 if ( memcmp(
buffer, ptr, c) != 0 ) {
501 if ( !
m_Ostream->write(s.data(), s.size()) ) {
548 const char* ptr =
str.data();
552 reinterpret_cast<const char*
>(memchr(ptr,
'\n',
size));
558 size_t lineSize = endl - ptr;
559 out.write(ptr, lineSize);
virtual ~CDelayedOfstream(void)
unique_ptr< CNcbiOfstream > m_Ostream
void open(const string &fileName)
CDelayedOfstream(const string &fileName)
unique_ptr< CNcbiIfstream > m_Istream
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
CNcbiOstream * m_StreamPtr
DestinationFile(const string &name, bool binary=false)
SSubString(const string &val, size_t ord)
CNcbiIstream * m_StreamPtr
EType GetType(void) const
bool x_Open(const string &name, bool binary)
SourceFile(const string &name, bool binary=false)
const_iterator find(const key_type &key) const
std::ofstream out("events_result.xml")
main entry point for tests
#define MAX_FILE_NAME_LENGTH
CNcbiOstream & Write(CNcbiOstream &out, const CNcbiOstrstream &src)
CNcbiOstream & WriteTabbed(CNcbiOstream &out, const CNcbiOstrstream &code, const char *tab)
#define DIR_SEPARATOR_CHAR
#define ALL_SEPARATOR_CHARS
bool Empty(const CNcbiOstrstream &src)
#define DIR_SEPARATOR_CHAR2
string DirName(const string &path)
string MakeFileName(const string &fname, size_t addLength)
string BaseName(const string &path)
string Path(const string &dir, const string &file)
static const int BUFFER_SIZE
#define DISK_SEPARATOR_CHAR
string GetStdPath(const string &path)
string MakeAbsolutePath(const string &path)
bool IsLocalPath(const string &path)
bool IsDirSeparator(char c)
bool IsDiskSeparator(char c)
static void DLIST_NAME() remove(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Fatal(CExceptionArgs_Base &args)
static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)
Normalize a path.
static bool IsAbsolutePath(const string &path)
Check if a "path" is absolute for the current OS.
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
static string GetCwd(void)
Get the current working directory.
string GetExt(void) const
Get extension name.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
bool IsOssEmpty(CNcbiOstrstream &oss)
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Int8 GetOssSize(CNcbiOstrstream &oss)
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
NCBI_NS_STD::string::size_type SIZE_TYPE
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
@ eNocase
Case insensitive compare.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
const struct ncbi::grid::netcache::search::fields::SIZE size
const CharType(& source)[N]
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
string Identifier(const string &typeName, bool capitalize)
bool operator()(const SSubString &s1, const SSubString &s2) const
bool operator()(const SSubString &s1, const SSubString &s2) const