primatologist-gpl 6.0.4
file.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef PRIMATOLOGIST_UTILITY_FILE_H
12#define PRIMATOLOGIST_UTILITY_FILE_H
13
14#include <cartobase/stream/fileutil.h> // carto::FileUtil
15#include <cartobase/stream/directory.h> // carto::Directory
16#include <string>
17
18namespace aims {
19namespace file {
20
23 std::string mkdir( std::string dirname, bool create_parents = false )
24 {
25 if( dirname.size() > 1 &&
26 dirname[ dirname.size() - 1 ] == carto::FileUtil::separator() )
27 {
28 dirname.erase( dirname.size() - 1 );
29 }
30
31 carto::Directory dir( dirname );
32 if( create_parents )
33 dir.makedirs();
34 else
35 dir.mkdir();
36
37 return dirname;
38 }
39
40} // namespace file
41} // namespace aims
42
43#endif // PRIMATOLOGIST_UTILITY_FILE_H
std::string mkdir(std::string dirname, bool create_parents=false)
if necessary, makes the directory and (optionnaly) its parents.
Definition file.h:23