FreeNOS
mkdir.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <FileSystemClient.h>
19 #include "errno.h"
20 #include "limits.h"
21 #include "stdio.h"
22 #include "string.h"
23 #include "sys/stat.h"
24 
25 int mkdir(const char *path, mode_t mode)
26 {
27  const FileSystemClient filesystem;
28 
29  // Ask FileSystem to create the file for us
30  const FileSystem::Result result = filesystem.createFile(path,
33  // Set errno
34  if (result == FileSystem::Success)
35  errno = ESUCCESS;
36  else
37  errno = EIO;
38 
39  // Report result
40  return errno == ESUCCESS ? 0 : -1;
41 }
FileSystemClient::createFile
FileSystem::Result createFile(const char *path, const FileSystem::FileType type, const FileSystem::FileModes mode) const
Create a new file.
Definition: FileSystemClient.cpp:169
errno
C int errno
The lvalue errno is used by many functions to return error values.
string.h
FileSystemClient
FileSystemClient provides a simple interface to a FileSystemServer.
Definition: FileSystemClient.h:42
ESUCCESS
#define ESUCCESS
Reports a success operation.
Definition: errno.h:43
mode_t
uint mode_t
Used for some file attributes.
Definition: types.h:47
FileSystem::Success
@ Success
Definition: FileSystem.h:54
FILEMODE_MASK
#define FILEMODE_MASK
Masker value for all FileMode values.
Definition: stat.h:45
limits.h
mkdir
int mkdir(const char *path, mode_t mode)
Create a new directory.
Definition: mkdir.cpp:25
stdio.h
EIO
#define EIO
I/O error.
Definition: errno.h:130
FileSystem::DirectoryFile
@ DirectoryFile
Definition: FileSystem.h:73
FileSystem::FileModes
u16 FileModes
Multiple FileMode values combined.
Definition: FileSystem.h:108
stat.h
FileSystemClient.h
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
errno.h