cwFileSys.cpp, cwMtx.h, cwObject.cpp : minor changes to eliminate warning during non-debug build.
This commit is contained in:
parent
ae68c2677c
commit
e86067659a
181
cwFileSys.cpp
181
cwFileSys.cpp
@ -299,111 +299,112 @@ cw::filesys::pathPart_t* cw::filesys::pathParts( const char* pathStr )
|
|||||||
// if pathStr is empty
|
// if pathStr is empty
|
||||||
if( n == 0 )
|
if( n == 0 )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
||||||
char buf[n+1];
|
|
||||||
buf[n] = 0;
|
|
||||||
|
|
||||||
// Get the last word (which may be a file name) from pathStr.
|
|
||||||
// (pathStr must be copied into a buf because basename()
|
|
||||||
// is allowed to change the values in its arg.)
|
|
||||||
strncpy(buf,pathStr,n);
|
|
||||||
cp = basename(buf);
|
|
||||||
|
|
||||||
if( cp != nullptr )
|
|
||||||
{
|
|
||||||
char* ep;
|
|
||||||
// does the last word have a period in it
|
|
||||||
if( (ep = strchr(cp,'.')) != nullptr )
|
|
||||||
{
|
|
||||||
*ep = 0; // end the file name at the period
|
|
||||||
++ep; // set the ext marker
|
|
||||||
en = strlen(ep); // get the length of the ext
|
|
||||||
}
|
|
||||||
|
|
||||||
fn = strlen(cp); //get the length of the file name
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the directory part.
|
|
||||||
// ( pathStr must be copied into a buf because dirname()
|
|
||||||
// is allowed to change the values in its arg.)
|
|
||||||
strncpy(buf,pathStr,n);
|
|
||||||
|
|
||||||
// if the last char in pathStr[] is '/' then the whole string is a dir.
|
|
||||||
// (this is not the answer that dirname() and basename() would give).
|
|
||||||
if( pathStr[n-1] == cwPathSeparatorChar )
|
|
||||||
{
|
|
||||||
fn = 0;
|
|
||||||
en = 0;
|
|
||||||
dn = n;
|
|
||||||
cp = buf;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cp = dirname(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
char buf[n+1];
|
||||||
|
buf[n] = 0;
|
||||||
|
|
||||||
if( cp != nullptr )
|
// Get the last word (which may be a file name) from pathStr.
|
||||||
dn = strlen(cp);
|
// (pathStr must be copied into a buf because basename()
|
||||||
|
// is allowed to change the values in its arg.)
|
||||||
// get the total size of the returned memory. (add 3 for ecmh possible terminating zero)
|
strncpy(buf,pathStr,n);
|
||||||
n = sizeof(pathPart_t) + dn + fn + en + 3;
|
|
||||||
|
|
||||||
// alloc memory
|
|
||||||
if((rp = (pathPart_t*)mem::allocZ<char>( n )) == nullptr )
|
|
||||||
{
|
|
||||||
cwLogError( kMemAllocFailRC, "Unable to allocate the file system path part record for '%s'.",pathStr);
|
|
||||||
goto errLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the return pointers for each of the parts
|
|
||||||
rp->dirStr = (const char* )(rp + 1);
|
|
||||||
rp->fnStr = rp->dirStr + dn + 1;
|
|
||||||
rp->extStr = rp->fnStr + fn + 1;
|
|
||||||
|
|
||||||
|
|
||||||
// if there is a directory part
|
|
||||||
if( dn>0 )
|
|
||||||
strcpy((char*)rp->dirStr,cp);
|
|
||||||
else
|
|
||||||
rp->dirStr = nullptr;
|
|
||||||
|
|
||||||
if( fn || en )
|
|
||||||
{
|
|
||||||
// Get the trailing word again.
|
|
||||||
// pathStr must be copied into a buf because basename() may
|
|
||||||
// is allowed to change the values in its arg.
|
|
||||||
strcpy(buf,pathStr);
|
|
||||||
cp = basename(buf);
|
cp = basename(buf);
|
||||||
|
|
||||||
|
|
||||||
if( cp != nullptr )
|
if( cp != nullptr )
|
||||||
{
|
{
|
||||||
|
|
||||||
char* ep;
|
char* ep;
|
||||||
|
// does the last word have a period in it
|
||||||
if( (ep = strchr(cp,'.')) != nullptr )
|
if( (ep = strchr(cp,'.')) != nullptr )
|
||||||
{
|
{
|
||||||
*ep = 0;
|
*ep = 0; // end the file name at the period
|
||||||
++ep;
|
++ep; // set the ext marker
|
||||||
|
en = strlen(ep); // get the length of the ext
|
||||||
cwAssert( strlen(ep) == en );
|
|
||||||
strcpy((char*)rp->extStr,ep);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn = strlen(cp); //get the length of the file name
|
||||||
cwAssert( strlen(cp) == fn );
|
|
||||||
if(fn)
|
|
||||||
strcpy((char*)rp->fnStr,cp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the directory part.
|
||||||
|
// ( pathStr must be copied into a buf because dirname()
|
||||||
|
// is allowed to change the values in its arg.)
|
||||||
|
strncpy(buf,pathStr,n);
|
||||||
|
|
||||||
|
// if the last char in pathStr[] is '/' then the whole string is a dir.
|
||||||
|
// (this is not the answer that dirname() and basename() would give).
|
||||||
|
if( pathStr[n-1] == cwPathSeparatorChar )
|
||||||
|
{
|
||||||
|
fn = 0;
|
||||||
|
en = 0;
|
||||||
|
dn = n;
|
||||||
|
cp = buf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cp = dirname(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( cp != nullptr )
|
||||||
|
dn = strlen(cp);
|
||||||
|
|
||||||
|
// get the total size of the returned memory. (add 3 for ecmh possible terminating zero)
|
||||||
|
n = sizeof(pathPart_t) + dn + fn + en + 3;
|
||||||
|
|
||||||
|
// alloc memory
|
||||||
|
if((rp = (pathPart_t*)mem::allocZ<char>( n )) == nullptr )
|
||||||
|
{
|
||||||
|
cwLogError( kMemAllocFailRC, "Unable to allocate the file system path part record for '%s'.",pathStr);
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the return pointers for each of the parts
|
||||||
|
rp->dirStr = (const char* )(rp + 1);
|
||||||
|
rp->fnStr = rp->dirStr + dn + 1;
|
||||||
|
rp->extStr = rp->fnStr + fn + 1;
|
||||||
|
|
||||||
|
|
||||||
|
// if there is a directory part
|
||||||
|
if( dn>0 )
|
||||||
|
strcpy((char*)rp->dirStr,cp);
|
||||||
|
else
|
||||||
|
rp->dirStr = nullptr;
|
||||||
|
|
||||||
|
if( fn || en )
|
||||||
|
{
|
||||||
|
// Get the trailing word again.
|
||||||
|
// pathStr must be copied into a buf because basename() may
|
||||||
|
// is allowed to change the values in its arg.
|
||||||
|
strcpy(buf,pathStr);
|
||||||
|
cp = basename(buf);
|
||||||
|
|
||||||
|
|
||||||
|
if( cp != nullptr )
|
||||||
|
{
|
||||||
|
|
||||||
|
char* ep;
|
||||||
|
if( (ep = strchr(cp,'.')) != nullptr )
|
||||||
|
{
|
||||||
|
*ep = 0;
|
||||||
|
++ep;
|
||||||
|
|
||||||
|
cwAssert( strlen(ep) == en );
|
||||||
|
strcpy((char*)rp->extStr,ep);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cwAssert( strlen(cp) == fn );
|
||||||
|
if(fn)
|
||||||
|
strcpy((char*)rp->fnStr,cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fn == 0 )
|
||||||
|
rp->fnStr = nullptr;
|
||||||
|
|
||||||
|
if( en == 0 )
|
||||||
|
rp->extStr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fn == 0 )
|
|
||||||
rp->fnStr = nullptr;
|
|
||||||
|
|
||||||
if( en == 0 )
|
|
||||||
rp->extStr = nullptr;
|
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
return rp;
|
return rp;
|
||||||
}
|
}
|
||||||
|
5
cwMtx.h
5
cwMtx.h
@ -145,7 +145,10 @@ namespace cw
|
|||||||
if( cwIsFlag(flags,kDuplDataFl) )
|
if( cwIsFlag(flags,kDuplDataFl) )
|
||||||
{
|
{
|
||||||
assert( aliasFl == false );
|
assert( aliasFl == false );
|
||||||
memcpy(m->base,base, eleN*sizeof(T) );
|
assert( base != nullptr );
|
||||||
|
|
||||||
|
if( base != nullptr )
|
||||||
|
memcpy(m->base,base, eleN*sizeof(T) );
|
||||||
}
|
}
|
||||||
|
|
||||||
m->flags = flags;
|
m->flags = flags;
|
||||||
|
@ -233,8 +233,8 @@ namespace cw
|
|||||||
unsigned _objTypeToStringUInt16( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u16); }
|
unsigned _objTypeToStringUInt16( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u16); }
|
||||||
unsigned _objTypeToStringInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.i32); }
|
unsigned _objTypeToStringInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.i32); }
|
||||||
unsigned _objTypeToStringUInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u32); }
|
unsigned _objTypeToStringUInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u32); }
|
||||||
unsigned _objTypeToStringInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.i64);*/ }
|
unsigned _objTypeToStringInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.i64);*/ return kInvalidOpRC; }
|
||||||
unsigned _objTypeToStringUInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.u64);*/ }
|
unsigned _objTypeToStringUInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.u64);*/ return kInvalidOpRC; }
|
||||||
unsigned _objTypeToStringBool( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.b); }
|
unsigned _objTypeToStringBool( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.b); }
|
||||||
unsigned _objTypeToStringFloat( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.f); }
|
unsigned _objTypeToStringFloat( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.f); }
|
||||||
unsigned _objTypeToStringDouble( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.d); }
|
unsigned _objTypeToStringDouble( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.d); }
|
||||||
@ -325,7 +325,7 @@ namespace cw
|
|||||||
object_t* _objTypeDuplDouble( const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<double >(parent,src->u.d ); }
|
object_t* _objTypeDuplDouble( const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<double >(parent,src->u.d ); }
|
||||||
object_t* _objTypeDuplString( const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<char* >(parent,mem::duplStr(src->u.str)); }
|
object_t* _objTypeDuplString( const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<char* >(parent,mem::duplStr(src->u.str)); }
|
||||||
object_t* _objTypeDuplCString(const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<const char*>(parent,mem::duplStr(src->u.str));}
|
object_t* _objTypeDuplCString(const struct object_str* src, struct object_str* parent ) { return _objCreateValueNode<const char*>(parent,mem::duplStr(src->u.str));}
|
||||||
object_t* _objTypeDuplVect( const struct object_str* src, struct object_str* parent ) { assert(0); }
|
object_t* _objTypeDuplVect( const struct object_str* src, struct object_str* parent ) { assert(0); return nullptr; }
|
||||||
object_t* _objTypeDuplPair( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
object_t* _objTypeDuplPair( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
||||||
object_t* _objTypeDuplList( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
object_t* _objTypeDuplList( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
||||||
object_t* _objTypeDuplDict( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
object_t* _objTypeDuplDict( const struct object_str* src, struct object_str* parent ) { return _objTypeDuplContainer(src,parent); }
|
||||||
|
Loading…
Reference in New Issue
Block a user