vxworks dosfs文件系统文件读写测试
来源:互联网 发布:java和c语言的区别 编辑:程序博客网 时间:2024/04/27 18:48
/**
******************************************************************************
* @file dosfsTest.c
* @author Daniel_Lee
* @version V1.0
* @date 2013.7.15
* @brief This is a test of using dosfs.
******************************************************************************
**/
/* Includes ------------------------------------------------------------------*/
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"#include "sysLib.h"
#include "logLib.h"
#include "dosfsLib.h"
#include "ioLib.h"
#include "stdio.h"
int fd,bytes = 0, length = 0;
unsigned char buf[64] = "Hello,I'm testing the file system";
unsigned char revBuf[64] = {0};
/*fd = creat("/D/my.txt",O_RDWR);
if(fd == -1){
logMsg("error: creat file failed\r\n",0,0,0,0,0,0);
return ERROR;
}*/
fd = open("/D/my.txt",O_RDWR,0);
if(fd == -1){
logMsg("error: open file failed\r\n",0,0,0,0,0,0);
return ERROR;
}
bytes = write(fd,buf,sizeof("Hello,I'm testing the file system"));
logMsg("write %d bytes data\r\n",bytes,0,0,0,0,0);
if(bytes != sizeof("Hello,I'm testing the file system")){
logMsg("error: write %d bytes data\r\n",bytes,0,0,0,0,0);
close(fd);
return ERROR;
}
close(fd);
fd = open("/D/my.txt",O_RDWR,0);
if(fd == -1){
logMsg("error: open file failed\r\n",0,0,0,0,0,0);
return ERROR;
}
bytes = read(fd,revBuf,sizeof(revBuf));
logMsg("read %d bytes data\r\n",bytes,0,0,0,0,0);
revBuf[9] = '\0';
logMsg("read %d bytes data, and read date is %s\r\n",bytes,revBuf,0,0,0,0);
close(fd);
return OK;
}
实验总结:数组在初始化时必须指明分配的空间大小,不能用变量初始化。
不能write后立马去读数据,因为在写数据的时候文件指针已经指向了文件尾部,马上读的话什么也读不出来,需要使用lseek设置偏移指针才可正确读出。
- vxworks dosfs文件系统文件读写测试
- vxWorks下dosFs文件系统的创建
- Ext2文件系统—文件读写
- Python 文件读写及文件系统
- sysfs文件系统之读写文件
- 读写文件速度测试
- 读写文件速度测试
- 读写文件速度测试
- verilog读写文件测试
- 读写文件速度测试
- 文件读写方式测试
- VxWorks 串口读写操作
- Linux文件系统之文件的读写
- UBIFS文件系统分析5 - 文件读写
- linux文件系统omfs文件的读写
- Linux文件系统之文件的读写
- Linux文件系统之文件的读写
- 详解ios文件系统文件目录读写操作
- PAT_1011: World Cup Betting
- 语音识别
- 学生信息管理系统
- java 内return语句总结
- 怎么利用Lucene.Net搜索结果,实现伪静态的文章列表
- vxworks dosfs文件系统文件读写测试
- Xcode使用教程详细讲解
- MPC8313E学习记录(2)
- 电驴提示“该内容尚未提供权利证明,无法提供下载”之解决办法详解
- 数据包上传到shopex商城后图片显示有问题的解决方法
- C语言 打印*号金字塔~~~
- 关于iOS App的切图 .
- dom4j解析xml字符串实例
- 通过手机远程关机