_WCRTLINK int __F_NAME(mkdir,_wmkdir)( const CHAR_TYPE *path ) /************************************************************/ { #ifdef __WIDECHAR__ size_t rcConvert; char mbcsPath[MB_CUR_MAX * _MAX_PATH]; unsigned char *p; /*** Convert the wide character string to a multibyte string ***/ rcConvert = wcstombs( mbcsPath, path, sizeof( mbcsPath ) ); p = _mbsninc( (unsigned char *)mbcsPath, rcConvert ); *p = '\0'; return( mkdir( mbcsPath ) ); #else #ifdef __WATCOM_LFN__ tiny_ret_t rc = 0; if( _RWD_uselfn && TINY_OK( rc = _mkdir_lfn( path ) ) ) { return( 0 ); } if( IS_LFN_ERROR( rc ) ) { return( __set_errno_dos( TINY_INFO( rc ) ) ); } #endif return( __mkdir_sfn( path ) ); #endif }
_WCRTLINK int __F_NAME(unlink,_wunlink)( const CHAR_TYPE *filename ) /******************************************************************/ { #ifdef __WIDECHAR__ char mbFilename[MB_CUR_MAX * _MAX_PATH]; /* single-byte char */ if( wcstombs( mbFilename, filename, sizeof( mbFilename ) ) == -1 ) { mbFilename[0] = '\0'; } return( unlink( mbFilename ) ); #else #ifdef __WATCOM_LFN__ unsigned rc = 0; if( _RWD_uselfn && (rc = _unlink_lfn( filename )) == 0 ) { return( 0 ); } if( IS_LFN_ERROR( rc ) ) { return( -1 ); } #endif if( __unlink_sfn( filename ) ) { return( -1 ); } return( 0 ); #endif }
_WCRTLINK unsigned _dos_getfileattr( const char *path, unsigned *attrib ) /***********************************************************************/ { #ifdef __WATCOM_LFN__ unsigned rc = 0; if( _RWD_uselfn && (rc = _dos_getfileattr_lfn( path, attrib )) == 0 ) { return( rc ); } if( IS_LFN_ERROR( rc ) ) { return( rc ); } #endif return( __dos_getfileattr_sfn( path, attrib ) ); }
_WCRTLINK unsigned _dos_open( const char *path, unsigned mode, int *handle ) /**************************************************************************/ { #ifdef __WATCOM_LFN__ tiny_ret_t rc = 0; if( _RWD_uselfn && TINY_OK( rc = __dos_open_lfn( path, mode ) ) ) { *handle = TINY_INFO( rc ); return( 0 ); } if( IS_LFN_ERROR( rc ) ) { return( __set_errno_dos_reterr( TINY_INFO( rc ) ) ); } #endif return( __dos_open_sfn_err( path, mode, handle ) ); }
_WCRTLINK unsigned _dos_findfirst( const char *path, unsigned attrib, struct find_t *fdta ) /******************************************************************************/ { #ifdef __WATCOM_LFN__ lfnfind_t lfndta; tiny_ret_t rc = 0; LFN_SIGN_OF( fdta ) = 0; LFN_HANDLE_OF( fdta ) = 0; if( _RWD_uselfn && TINY_OK( rc = _dos_find_first_lfn( path, attrib, &lfndta ) ) ) { convert_to_find_t( fdta, &lfndta ); LFN_SIGN_OF( fdta ) = _LFN_SIGN; LFN_HANDLE_OF( fdta ) = TINY_INFO( rc ); return( 0 ); } if( IS_LFN_ERROR( rc ) ) { return( __set_errno_dos_reterr( TINY_INFO( rc ) ) ); } #endif return( __dos_find_first_dta( path, attrib, fdta ) ); }
_WCRTLINK int fstat( int handle, struct stat *buf ) { unsigned iomode_flags; tiny_ret_t rc; __handle_check( handle, -1 ); rc = TinyGetDeviceInfo( handle ); if( TINY_ERROR( rc ) ) { return( __set_errno_dos( TINY_INFO( rc ) ) ); } /* isolate drive number */ buf->st_dev = TINY_INFO( rc ) & TIO_CTL_DISK_DRIVE_MASK; buf->st_rdev = buf->st_dev; buf->st_nlink = 1; buf->st_uid = buf->st_gid = 0; buf->st_ino = handle; buf->st_mode = 0; iomode_flags = __GetIOMode( handle ); if( iomode_flags & _READ ) { buf->st_mode |= S_IRUSR | S_IRGRP | S_IROTH; } if( iomode_flags & _WRITE ) { buf->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; } if( TINY_INFO( rc ) & TIO_CTL_DEVICE ) { buf->st_size = 0; buf->st_atime = buf->st_ctime = buf->st_mtime = 0; buf->st_mode |= S_IFCHR; } else { /* file */ #ifdef __WATCOM_LFN__ lfninfo_t lfni; rc = 0; if( _RWD_uselfn && TINY_OK( rc = _getfileinfo_lfn( handle, &lfni ) ) ) { buf->st_mtime = _cvt_stamp2ttime_lfn( &lfni.writetimestamp ); if( lfni.creattimestamp ) { buf->st_ctime = _cvt_stamp2ttime_lfn( &lfni.creattimestamp ); } else { buf->st_ctime = buf->st_mtime; } if( lfni.accesstimestamp ) { buf->st_atime = _cvt_stamp2ttime_lfn( &lfni.accesstimestamp ); } else { buf->st_atime = buf->st_mtime; } buf->st_size = lfni.lfilesize; buf->st_attr = lfni.attributes; } else if( IS_LFN_ERROR( rc ) ) { return( __set_errno_dos( TINY_INFO( rc ) ) ); } else { #endif long rc1; rc1 = __getfilestamp_sfn( handle ); if( rc1 == -1 ) { return( -1 ); } buf->st_mtime = _d2ttime( rc1 >> 16, rc1 ); buf->st_atime = buf->st_mtime; buf->st_ctime = buf->st_mtime; buf->st_size = filelength( handle ); buf->st_attr = 0; #ifdef __WATCOM_LFN__ } #endif buf->st_mode |= S_IFREG; } buf->st_btime = buf->st_mtime; buf->st_archivedID = 0; buf->st_updatedID = 0; buf->st_inheritedRightsMask = 0; buf->st_originatingNameSpace = 0; return( 0 ); }