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
Post a Comment