zoukankan      html  css  js  c++  java
  • iOS-NSFileManager

    NSString * path = [path lastPathCompoment];获取相对路径
    NSArray * directory = [[NSFileManager defaunltManager] directoryContentsAtPath:path];
    获取目录下内容;
    NSString*PATH2 = NSHomeDirectory();得到应用程序主目录;
    BOOL myPathIsDir;
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:selectedPath isDirectory &myPathIsDir];
    判断当前路径是目录还是文件;
    -(void)updataFileOverview{
    NSString * fileName = [self.filePath lastPathCompnent];
     NSDataForMatter *dateMatter = [[NSDataForMatter alloc] init];
    [dataForMatter setDataStyle: NSDateForMatterMediumStyle];
    [dataForMatter setTimeStyle:NSDateForMatterNoStyle];
    NSNumberFormatter * numberMatter = [[NSNumberFormatter alloc] init];
    [numberMatter setPositiveForMat:@"#,##0.## bytes"];
     
    NSDictionary *fileAttributes =[ [NSfileManager defaultManager] fileAttributesAtPath:self.filePath traverseLink:YES];
    }
    异步读文件
    {
    NSInputStream * inputStream = [[NSInputStream alloc] initWithFileAtPath:filepath];
    [inputStrem setDelegate:self];
    [inputStream scheduleInputRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];//该调用指示当前线程的运行循环成为处理检查流状态的那个循环
    [inputStrem open];
    [inputStream release];
    }
    代理方法:
    -(void)strem:(NSStrem *)theStream handleEvent:(NSStreamEvent)streamEvent{
    NSInputStream *inputStream = (NSInputStream*) theStream;
    switch(streamEvent){
    case NSStremEventHasBytesAvailable:{有字节可读事件
    NSInteger maxLengh = 128;
    unit8_t readBuffer [maxLengh];
    NSInteger bytesRead = [inputStream read:readBuffer maxLengh:maxLengh];
    if(bytesRead>0)
        {NSString * bufferString = [[NSString alloc] initWithBytesNoCopy:radBuffer length: bytesRead ecoding:NSUTF8StringEcoding     freeWhenDone:NO];
        [self appendTextToView:bufferString];
        [bufferString release];
        }break;
     
    }
    case
    }
    }
  • 相关阅读:
    【转】漫谈linux文件IO--io流程讲的很清楚
    iostat命令
    【转】ATA Secure Erase
    同步IO和异步IO
    fio2.1.10--README
    【转】地址空间、内核空间、IO地址空间
    博客收藏--sailing的博客
    Cosmos OpenSSD架构分析--HOST interface(未完)
    nginx 过滤zip 类型的文件
    freeswitch GUI界面(portal)
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5086007.html
Copyright © 2011-2022 走看看