当前位置: 首页>>代码示例>>C++>>正文


C++ FileSystem::createDirectory方法代码示例

本文整理汇总了C++中FileSystem::createDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::createDirectory方法的具体用法?C++ FileSystem::createDirectory怎么用?C++ FileSystem::createDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem::createDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

    void run() {

        fileSystem.mountDisk(0);

        fileSystem.createDirectory("newDir");
        bool isDir;
        fileSystem.fileExists("newDir", &isDir);

        //fill directory with files
        fileSystem.move("test.txt", "newDir/test.txt");

        //open and interate through directory
        directory.open("newDir");
        directory.resetEntryEnumeration();
        
        char nextFileName[100];
        int32_t size;
        directory.readNextEntry(nextFileName, 100, &size);

        while (nextFileName[0] != '\0') {
            PRINTF("next entry in newDir is %s\nsize: %ld\n", nextFileName, size);
            directory.readNextEntry(nextFileName, 100, &size);
        }

        //this will remove the disk
        //fileSystem->unmountDisk(0);
        PRINTF("please ^C to terminate\n");
    }
开发者ID:art1,项目名称:FloatSat-Project-G9,代码行数:28,代码来源:directory.cpp

示例2: run

 void run() {
    //we prefer to have pointers so we create these:
    FileSystem* fileSystem = &fs_;
    File* file = &f_;
    Directory* d = &d_;


    xprintf("\n////////////////////////////\n"
            "main > TESTING INIT AND MOUNT\n"
            "//////////////////////\n");

    fileSystem->enableDebugOutput(true);

    //disk must be mounted before anything else can be done
    fileSystem->mountDisk(0);
    xprintf("main > mount done\n");

    //format will create a new fat file system
    //this can be omitted if there already is a fs on the disk
    fileSystem->formatDisk(0);
    xprintf("main > format done\n");


    //setting time changes RODOS system time
    fileSystem->setTime(2012, 03, 03, 07, 31, 12);



    xprintf("\n////////////////////////////\n"
            "main > TESTING DIRECTORY FUNTIONS\n"
            "///////////////////////////\n");

    file->enableDebugOutput(true);

    file->open("/test.txt", file->O_WRITE);
    file->putString("This is my first file!\n");
    file->close();
    xprintf("main > created '/test.txt'\n");



    //this will not work because it does not create intermediate directories
    xprintf("main > create dir '/FirstDir/ScndDir'\n");
    fileSystem->createDirectory("/FirstDir/ScndDir");

    bool isDir;
    bool exists = fileSystem->fileExists("/FirstDir/ScndDir", &isDir);
    if (!exists) {
        xprintf("main > directory '/FirstDir/ScndDir' does not exist -> correct\n");
    } else {
        xprintf("main > directory '/FirstDir/ScndDir' exists -> NOT CORRECT\n");
    }


    //if we create directories one after the other everything will work fine
    xprintf("main > create dir '/FirstDir'\n");
    fileSystem->createDirectory("/FirstDir");

    xprintf("main > create dir '/FirstDir/ScndDir'\n");
    fileSystem->createDirectory("/FirstDir/ScndDir");
    exists = fileSystem->fileExists("/FirstDir/ScndDir", &isDir);
    if (!exists) {
        xprintf("main > directory '/FirstDir/ScndDir' does not exist -> NOT CORRECT\n");
    } else {
        xprintf("main > directory '/FirstDir/ScndDir' exists -> correct\n");
    }


    //fill directory with files
    fileSystem->move("/test.txt", "/FirstDir/test.txt");

    file->open("FirstDir/file2.txt", file->O_WRITE);
    file->putString("This is file2, dude.");
    file->close();

    file->open("FirstDir/file3.txt", file->O_WRITE);
    file->putString("This is file3, bro.");
    file->close();

    //rename entire directory
    fileSystem->move("FirstDir", "MyDir");

    
    
    //open and interate through directory
    d->open("/MyDir");
    d->resetEntryEnumeration();
    xprintf("main > reset entry numeration on  '/MyDir/'\n");

    char nextFileName[100];
    long size;
    d->readNextEntry(nextFileName, 100, &size);

    while (nextFileName[0] != '\0') {
        xprintf("main > next entry in  '/MyDir/' is %s\nsize: %ld\n", nextFileName, size);
        char path[200];
        path[0] = 0;
        xsprintf(path, "/MyDir/%s", nextFileName);

        exists = fileSystem->fileExists(path, &isDir);
//.........这里部分代码省略.........
开发者ID:art1,项目名称:FloatSat-Project-G9,代码行数:101,代码来源:main_directory.cpp


注:本文中的FileSystem::createDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。