c++ - How to find out if final part of passed path is file, directory or mask? -


i'm trying make linux c++ code copy , list files arbitrary path, independently of protocol ( ftp, ssh, mtp, local, smb, etc ), wondering best way check if specified path simple folder path ( list in there ), path ending in file ( list 1 file ), or mask ( /path1/path2/*.xxx ).

the first 2 ones transparently handled code, third 1 eluding me...

right now, have this:

entry newentry ( path ); if newentry.isdirectory ()     {     newentry.listcontentsintoarray(array);     foreach entry in array         displayinfo ( entry );     } else     displayinfo ( newentry ); 

but have no idea how if ends in wildcard mask... ideas?

posix has got api wildcard expansion: glob():

c.f.

man 3p glob 

(if have got posix manpages installed on system).

note can hand plain directory , regular filenames glob(). might simplify code. can ask glob() append / each expanded entry if directory (flag: glob_mark).


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -