gushiyi 发表于 2010-11-10 17:38:06

UC/FS中的目录操作与文件操作是什么关系呢?

我现在移植了UC/FS到系统中,其中也加了nand flash的驱动,但是测试的时候FS_IoCtl(),FS_FOpen()等函数都用不成,格式化不成功,也打不开文件,莫非是我没有建立目录的原因吗??!那我没有建立目录就不能这样格式化了吗??
void MainTask(void) {
/* buffers used to read and write to file */
char acWriteText = "Hello World";
char acReadText;
FS_FILE* pFile;

/* if (FS_IoCtl("flash:",FS_CMD_FORMAT_MEDIA,FS_MEDIA_NAND_64MB,0)) {
   _error("Cannot format RAM disk.\n");
}*/
/* Now Flash is ready to be used with file system */
pFile = FS_FOpen("flash:\\hello.txt", "w+"); /* open a file for read/write */
FS_FWrite(acWriteText, 1, sizeof(acWriteText), pFile);   /* write to file */
FS_FSeek(pFile, 0, FS_SEEK_SET);                         /* set file position to 0 */
FS_FRead(acReadText, 1, sizeof(acReadText), pFile);      /* read the file */
_log("This text was written to flash:\\hello.txt: \n");
_log(acReadText);
FS_FClose(pFile);                                        /* Close the file */
}
单步调试的时候,FS_IoCtl(),看到这个函数里面的返回值idx是0的,但是在运行下一条语句的时候就变成了0XFFFFFFFF,我主要是不知道我直接按上面这样不能对flash进行文件的打开和读写吗??在这之前还要建立目录吗???或是有谁有示例可以参考下呢??
页: [1]
查看完整版本: UC/FS中的目录操作与文件操作是什么关系呢?