vxworks中如何创建一个文件,有没有例子
2个回答
展开全部
用普通的文件open()函数就可以了.
#include <ioLib.h>
open( )
NAME
open( ) - open a file
SYNOPSIS
int open
(
const char * name, /* name of the file to open */
int flags, /* O_RDONLY, O_WRONLY, O_RDWR, or O_CREAT */
int mode /* mode of file to create (UNIX chmod style) */
)
DESCRIPTION
This routine opens a file for reading, writing, or updating, and returns a file descriptor for that file. The arguments to open( ) are the filename and the type of access:
O_RDONLY (0) (or READ) - open for reading only.
O_WRONLY (1) (or WRITE) - open for writing only.
O_RDWR (2) (or UPDATE) - open for reading and writing.
O_CREAT (0x0200) - create a file.
In general, open( ) can only open pre-existing devices and files. However, for NFS network devices only, files can also be created with open( ) by performing a logical OR operation with O_CREAT and the flags argument. In this case, the file is created with a UNIX chmod-style file mode, as indicated with mode. For example:
fd = open ("/usr/myFile", O_CREAT | O_RDWR, 0644);
Only the NFS driver uses the mode argument.
NOTE
For more information about situations when there are no file descriptors available, see the manual entry for iosInit( ).
RETURNS
A file descriptor number, or ERROR if a file name is not specified, the device does not exist, no file descriptors are available, or the driver returns ERROR.
ERRNO
ELOOP
SEE ALSO
ioLib, creat( )
VARARGS2
其中creat和open效果一样,他们最终调用同一个函数,最终文件保存在你设置里放vxworks的位置,比如我的就放在D:\目录下了,试试看吧
#include <ioLib.h>
open( )
NAME
open( ) - open a file
SYNOPSIS
int open
(
const char * name, /* name of the file to open */
int flags, /* O_RDONLY, O_WRONLY, O_RDWR, or O_CREAT */
int mode /* mode of file to create (UNIX chmod style) */
)
DESCRIPTION
This routine opens a file for reading, writing, or updating, and returns a file descriptor for that file. The arguments to open( ) are the filename and the type of access:
O_RDONLY (0) (or READ) - open for reading only.
O_WRONLY (1) (or WRITE) - open for writing only.
O_RDWR (2) (or UPDATE) - open for reading and writing.
O_CREAT (0x0200) - create a file.
In general, open( ) can only open pre-existing devices and files. However, for NFS network devices only, files can also be created with open( ) by performing a logical OR operation with O_CREAT and the flags argument. In this case, the file is created with a UNIX chmod-style file mode, as indicated with mode. For example:
fd = open ("/usr/myFile", O_CREAT | O_RDWR, 0644);
Only the NFS driver uses the mode argument.
NOTE
For more information about situations when there are no file descriptors available, see the manual entry for iosInit( ).
RETURNS
A file descriptor number, or ERROR if a file name is not specified, the device does not exist, no file descriptors are available, or the driver returns ERROR.
ERRNO
ELOOP
SEE ALSO
ioLib, creat( )
VARARGS2
其中creat和open效果一样,他们最终调用同一个函数,最终文件保存在你设置里放vxworks的位置,比如我的就放在D:\目录下了,试试看吧
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2019-04-12
展开全部
mkdir “文件名”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询