MCPcopy Create free account
hub / github.com/buggins/coolreader / LVExtractFirstPathElement

Function LVExtractFirstPathElement

crengine/src/lvstream.cpp:3529–3549  ·  view source on GitHub ↗

removes first path part from pathname and returns it

Source from the content-addressed store, hash-verified

3527
3528/// removes first path part from pathname and returns it
3529lString16 LVExtractFirstPathElement( lString16 & pathName )
3530{
3531 if ( pathName.empty() )
3532 return lString16();
3533 if ( pathName[0]=='/' || pathName[0]=='\\' )
3534 pathName.erase(0, 1);
3535 int first_delim_pos = -1;
3536 for ( unsigned i=0; i<pathName.length(); i++ )
3537 if ( pathName[i]=='/' || pathName[i]=='\\' ) {
3538 first_delim_pos = i;
3539 break;
3540 }
3541 if ( first_delim_pos==-1 ) {
3542 lString16 res = pathName;
3543 pathName.clear();
3544 return res;
3545 }
3546 lString16 res = pathName.substr(0, first_delim_pos );
3547 pathName.erase(0, first_delim_pos+1 );
3548 return res;
3549}
3550
3551/// appends path delimiter character to end of path, if absent
3552void LVAppendPathDelimiter( lString16 & pathName )

Callers 1

LVMakeRelativeFilenameFunction · 0.85

Calls 6

lString16Class · 0.85
emptyMethod · 0.45
eraseMethod · 0.45
lengthMethod · 0.45
clearMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected