summaryrefslogtreecommitdiff
path: root/ACE/ace/MQX_Filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/MQX_Filesystem.cpp')
-rw-r--r--ACE/ace/MQX_Filesystem.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/ACE/ace/MQX_Filesystem.cpp b/ACE/ace/MQX_Filesystem.cpp
index 3bdbe3cfb31..f04303d8675 100644
--- a/ACE/ace/MQX_Filesystem.cpp
+++ b/ACE/ace/MQX_Filesystem.cpp
@@ -23,7 +23,7 @@
MQX_Filesystem MQX_Filesystem::instance_;
MQX_Filesystem::MQX_Filesystem ()
- : current_fs_ (NULL)
+ : current_fs_ (0)
, current_fs_name_len_ (0)
, max_fd_ (255)
, last_fd_ (-1)
@@ -34,7 +34,7 @@ MQX_Filesystem::MQX_Filesystem ()
for (unsigned i = 0; i < FOPEN_MAX; i++)
{
files_[i].fd = -1;
- files_[i].mqx_file = NULL;
+ files_[i].mqx_file = 0;
}
}
@@ -71,9 +71,9 @@ bool
MQX_Filesystem::reset_state ()
{
update_fs (_io_get_first_valid_fs ());
- if (current_fs_ != NULL)
+ if (current_fs_ != 0)
chdir ("\\");
- return current_fs_ == NULL;
+ return current_fs_ == 0;
}
void
@@ -81,7 +81,7 @@ MQX_Filesystem::update_fs (MQX_FILE_PTR fs)
{
current_fs_ = fs;
bool invalid = false;
- if (fs == NULL)
+ if (fs == 0)
invalid = true;
else if (_io_get_fs_name (fs, current_fs_name_, IOCFG_FS_MAX_DEVLEN) != MQX_OK)
invalid = true;
@@ -90,7 +90,7 @@ MQX_Filesystem::update_fs (MQX_FILE_PTR fs)
if (invalid)
{
- current_fs_ = NULL;
+ current_fs_ = 0;
current_fs_name_[0] = '\0';
current_fs_name_len_ = 0;
}
@@ -135,11 +135,11 @@ MQX_Filesystem::open (const char *path, int mode)
// Set up a new File Entry
File *file = get_new_file ();
- if (file == NULL) return -1;
+ if (file == 0) return -1;
// Call into MQX
file->mqx_file = _io_fopen (abspath, cstdlib_mode);
- if (file->mqx_file == NULL)
+ if (file->mqx_file == 0)
{
file->fd = -1; // Free File in Our Array
errno = ACE_OS::mqx_error_to_errno (_task_get_error());
@@ -154,7 +154,7 @@ int
MQX_Filesystem::close (int fd)
{
File *file = get_file (fd);
- if (file == NULL) return -1;
+ if (file == 0) return -1;
int mqx_error = _io_fclose (file->mqx_file);
if (mqx_error != MQX_OK)
{
@@ -168,7 +168,7 @@ size_t
MQX_Filesystem::read (int fd, unsigned char *buffer, size_t size)
{
File *file = get_file (fd);
- if (file == NULL) return MQX_FILE_ERROR;
+ if (file == 0) return MQX_FILE_ERROR;
int result = _io_read (file->mqx_file, buffer, size);
if (result == IO_ERROR)
{
@@ -182,7 +182,7 @@ size_t
MQX_Filesystem::write (int fd, const unsigned char *buffer, size_t size)
{
File *file = get_file (fd);
- if (file == NULL) return MQX_FILE_ERROR;
+ if (file == 0) return MQX_FILE_ERROR;
int result = _io_write (file->mqx_file, const_cast<unsigned char *> (buffer), size);
if (result == IO_ERROR)
{
@@ -211,18 +211,18 @@ MQX_Filesystem::lseek (int fd, long offset, int whence)
return -1;
}
File *file = get_file (fd);
- if (file == NULL) return -1;
+ if (file == 0) return -1;
return _io_fseek (file->mqx_file, offset, whence) == MQX_OK ? 0 : -1;
}
char*
MQX_Filesystem::getcwd (char *buf, size_t size)
{
- if (check_state ()) return NULL;
- if (buf == NULL)
+ if (check_state ()) return 0;
+ if (buf == 0)
{
errno = EINVAL;
- return NULL;
+ return 0;
}
char curdirtmp[FS_FILENAME_SIZE];
@@ -230,12 +230,12 @@ MQX_Filesystem::getcwd (char *buf, size_t size)
if (mqx_error != MFS_NO_ERROR)
{
errno = ACE_OS::mqx_error_to_errno (mqx_error);
- return NULL;
+ return 0;
}
if ((current_fs_name_len_ + strlen (curdirtmp) + 1) > size)
{
errno = ERANGE;
- return NULL;
+ return 0;
}
strcpy (buf, current_fs_name_);
strcat (buf, curdirtmp);
@@ -245,12 +245,12 @@ MQX_Filesystem::getcwd (char *buf, size_t size)
MQX_FILE_PTR
MQX_Filesystem::resolve_fs (const char *path, int *fs_name_len)
{
- if (check_state ()) return NULL;
+ if (check_state ()) return 0;
- if (fs_name_len == NULL || path == NULL || path[0] == '\0')
+ if (fs_name_len == 0 || path == 0 || path[0] == '\0')
{
errno = EINVAL;
- return NULL;
+ return 0;
}
MQX_FILE_PTR fs;
char fs_name[IOCFG_FS_MAX_DEVLEN];
@@ -269,7 +269,7 @@ MQX_Filesystem::resolve_fs (const char *path, int *fs_name_len)
else
{
errno = EINVAL;
- fs = NULL;
+ fs = 0;
}
return fs;
}
@@ -279,7 +279,7 @@ MQX_Filesystem::mkdir (const char *path)
{
int fs_name_len;
MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
- if (fs == NULL) return -1;
+ if (fs == 0) return -1;
int mqx_error = _io_ioctl (
fs, IO_IOCTL_CREATE_SUBDIR, (uint32_t*) (path + fs_name_len));
if (mqx_error != MQX_OK)
@@ -295,7 +295,7 @@ MQX_Filesystem::chdir (const char *path)
{
int fs_name_len;
MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
- if (fs == NULL) return -1;
+ if (fs == 0) return -1;
if (fs != current_fs_) update_fs(fs);
int mqx_error = _io_ioctl (fs, IO_IOCTL_CHANGE_CURRENT_DIR,
(uint32_t*) (path + fs_name_len));
@@ -312,7 +312,7 @@ MQX_Filesystem::rmdir (const char *path)
{
int fs_name_len;
MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
- if (fs == NULL) return -1;
+ if (fs == 0) return -1;
int mqx_error = _io_ioctl (fs, IO_IOCTL_REMOVE_SUBDIR,
(uint32_t*) (path + fs_name_len));
if (mqx_error != MQX_OK)
@@ -328,7 +328,7 @@ MQX_Filesystem::unlink (const char *path)
{
int fs_name_len;
MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
- if (fs == NULL) return -1;
+ if (fs == 0) return -1;
int mqx_error = _io_ioctl (fs, IO_IOCTL_DELETE_FILE,
(uint32_t*) (path + fs_name_len));
if (mqx_error != MQX_OK)
@@ -347,7 +347,7 @@ MQX_Filesystem::rename (const char *oldpath, const char *newpath)
MQX_FILE_PTR fs = resolve_fs (oldpath, &old_fs_name_len);
int new_fs_name_len;
MQX_FILE_PTR other_fs = resolve_fs (newpath, &new_fs_name_len);
- if (fs == NULL || other_fs == NULL) return -1;
+ if (fs == 0 || other_fs == 0) return -1;
if (fs != other_fs)
{
errno = EXDEV;
@@ -405,7 +405,7 @@ MQX_Filesystem::get_file (int fd)
if (files_[i].fd == fd) return &files_[i];
}
errno = EBADF;
- return NULL;
+ return 0;
}
MQX_Filesystem::File *
@@ -413,13 +413,13 @@ MQX_Filesystem::get_new_file ()
{
// Get Unused File Struct
File *file = get_file (-1);
- if (file != NULL)
+ if (file != 0)
{
- file->mqx_file = NULL;
+ file->mqx_file = 0;
// Get Unused File Descriptor
for (int fd = last_fd_ + 1; fd != last_fd_; fd++)
{
- if (get_file (fd) == NULL)
+ if (get_file (fd) == 0)
{
file->fd = fd;
last_fd_ = fd;
@@ -429,7 +429,7 @@ MQX_Filesystem::get_new_file ()
}
}
errno = ENFILE;
- return NULL;
+ return 0;
}
static inline int
@@ -442,7 +442,7 @@ mfs_file_attrs_to_stat_mode (int attributes)
int
MQX_Filesystem::stat (const char * path, ACE_stat *statbuf)
{
- if (statbuf == NULL)
+ if (statbuf == 0)
{
errno = EINVAL;
return -1;
@@ -450,7 +450,7 @@ MQX_Filesystem::stat (const char * path, ACE_stat *statbuf)
int fs_name_len;
MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
- if (fs == NULL) return -1;
+ if (fs == 0) return -1;
statbuf->st_size = 0;
statbuf->st_mtime = 0;
@@ -480,14 +480,14 @@ MQX_Filesystem::stat (const char * path, ACE_stat *statbuf)
int
MQX_Filesystem::fstat (int fd, ACE_stat *statbuf)
{
- if (statbuf == NULL)
+ if (statbuf == 0)
{
errno = EINVAL;
return -1;
}
File *file = get_file (fd);
- if (file == NULL) return -1;
+ if (file == 0) return -1;
statbuf->st_size = 0;
statbuf->st_mtime = 0;