mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added get_parent_directory()
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403859
This commit is contained in:
parent
6efd2b750b
commit
6f2edac080
@ -34,6 +34,32 @@ namespace dlib
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const directory& dir
|
||||
)
|
||||
{
|
||||
return dir.get_parent();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const file& f
|
||||
)
|
||||
{
|
||||
if (f.full_name().size() == 0)
|
||||
return directory();
|
||||
|
||||
std::string::size_type pos = f.full_name().find_last_of("\\/");
|
||||
|
||||
if (pos == std::string::npos)
|
||||
return directory();
|
||||
|
||||
return directory(f.full_name().substr(0,pos));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
@ -93,6 +93,18 @@ namespace dlib
|
||||
) const { return true; }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const directory& dir
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const file& f
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
@ -91,6 +91,30 @@ namespace dlib
|
||||
!*/
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const directory& dir
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- returns the parent directory of dir. In particular, this
|
||||
function returns the value of dir.get_parent()
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
directory get_parent_directory (
|
||||
const file& f
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- if (f.full_name() != "") then
|
||||
- returns the directory which contains the given file
|
||||
- else
|
||||
- returns a default initialized directory (i.e. directory())
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace dlib
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- this function is idential to file(const std::string& name)
|
||||
- this function is identical to file(const std::string& name)
|
||||
!*/
|
||||
|
||||
file (
|
||||
@ -243,7 +243,7 @@ namespace dlib
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- this function is idential to directory(const std::string& name)
|
||||
- this function is identical to directory(const std::string& name)
|
||||
!*/
|
||||
|
||||
directory (
|
||||
|
Loading…
Reference in New Issue
Block a user