コード例 #1
0
ファイル: dirent.c プロジェクト: StratifyLabs/StratifyOS
/*! \details Reads the next directory entry in the open directory (reentrant version).
 *
 * \return a pointer to a dirent or NULL with errno (see \ref errno) set to:
 * - EBADF: \a dirp is invalid
 * - ENOENT: the current position of the directory stream is invalid
 *
 */
int readdir_r(DIR * dirp /*! a pointer to the directory structure */,
				  struct dirent * entry /*! a pointer to the destination memory */,
				  struct dirent ** result /*! this value is assigned to \a entry on success and NULL on failure */){
	int err;
	const sysfs_t * fs;
	if (check_ebadf(dirp) < 0 ){
		if ( result ){
			*result = NULL;
		}
		return -1;
	}

	fs = dirp->fs;
	err = fs->readdir_r(fs->config, dirp->handle, dirp->loc, entry);
	if ( err < 0 ){
		//errno is set by fs->readdir_r
		SYSFS_PROCESS_RETURN(err);
		if ( result ){
			*result = NULL;
		}
		return err;
	}

	dirp->loc++;
	cortexm_assign_zero_sum32(dirp, sizeof(DIR)/sizeof(u32));

	if ( result ){
		*result = entry;
	}
	return 0;
}
コード例 #2
0
ファイル: dirent.c プロジェクト: GDXN/CoActionOS-Public
/*! \details This function closes the directory stream specified by \a dirp.
 *
 * \return Zero or -1 with errno (see \ref ERRNO) set to:
 * - EINVAL: \a dirp does not refere to an open directory stream
 *
 */
int closedir(DIR * dirp /*! A pointer to the open directory */){
	if (check_ebadf(dirp) < 0 ){
		return -1;
	}
	free(dirp);
	return 0;
}
コード例 #3
0
ファイル: dirent.c プロジェクト: GDXN/CoActionOS-Public
/*! \details This function reads the next directory entry in the open directory (reentrant version).
 *
 * \return a pointer to a dirent or NULL with errno (see \ref ERRNO) set to:
 * - EBADF: \a dirp is invalid
 * - ENOENT: the current position of the directory stream is invalid
 *
 */
int readdir_r(DIR * dirp /*! a pointer to the directory structure */,
		struct dirent * entry /*! a pointer to the destination memory */,
		struct dirent ** result /*! this value is assigned to \a entry on success and NULL on failure */){
	int err;
	const sysfs_t * fs;
	if (check_ebadf(dirp) < 0 ){
		if ( result ){
			*result = NULL;
		}
		return -1;
	}

	fs = dirp->fs;
	err = fs->readdir_r(fs->cfg, dirp->handle, dirp->loc, entry);
	if ( err < 0 ){
		//errno is set by fs->readdir_r
		if ( result ){
			*result = NULL;
		}
		return -1;
	}

	dirp->loc++;

	if ( result ){
		*result = entry;
	}
	return 0;
}
コード例 #4
0
ファイル: dirent.c プロジェクト: StratifyLabs/StratifyOS
/*! \details Closes the directory stream specified by \a dirp.
 *
 * \return Zero or -1 with errno (see \ref errno) set to:
 * - EINVAL: \a dirp does not refere to an open directory stream
 *
 */
int closedir(DIR * dirp /*! A pointer to the open directory */){
	int ret;
	const sysfs_t * fs;

	if (check_ebadf(dirp) < 0 ){ return -1; }
	fs = dirp->fs;
	ret = fs->closedir(fs->config, &(dirp->handle));
	SYSFS_PROCESS_RETURN(ret);

	free(dirp);
	return ret;
}
コード例 #5
0
ファイル: dirent.c プロジェクト: StratifyLabs/StratifyOS
/*! \details Gets the current location in the directory.
 *
 * \return The current directory location
 */
long telldir(DIR * dirp /*! a pointer to the directory structure */){
	if( check_ebadf(dirp) < 0 ){ return SYSFS_RETURN_EOF; }
	return dirp->loc;
}
コード例 #6
0
ファイル: dirent.c プロジェクト: StratifyLabs/StratifyOS
/*! \details Seeks to the specified location in
 * the directory.
 *
 */
void seekdir(DIR * dirp /*! a pointer to the directory structure */,
				 long loc /*! the target location */){
	if( check_ebadf(dirp) < 0 ){ return; }
	dirp->loc = loc;
	cortexm_assign_zero_sum32(dirp, sizeof(DIR)/sizeof(u32));
}
コード例 #7
0
ファイル: dirent.c プロジェクト: StratifyLabs/StratifyOS
/*! \details Rewinds \a dirp.
 *
 */
void rewinddir(DIR * dirp /*! a pointer to the directory structure */){
	if( check_ebadf(dirp) < 0 ){ return; }
	dirp->loc = 0;
	cortexm_assign_zero_sum32(dirp, sizeof(DIR)/sizeof(u32));
}