#include <stdio.h>
//只可从App层的系统API获得沙盒中Documents 目录所在的绝对路径
//参数NSDocumentDirectory要获取那种路径
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//获取sandBox中Documents 目录所在的绝对路径
NSString *documentsDirectory = [paths objectAtIndex:0];
strcpy(global_debug_recording_path_, [documentsDirectory UTF8String]);
extern char global_debug_recording_path_[256];
char file_path1[1024] = {0,};
bool isCreated = false;
if(!isCreated) {
strcpy(file_path1, global_debug_recording_path_);
strcat(file_path1, "/Source.pcm");
file1 = fopen((const char*)file_path1, "w+");
if (file1) {
isCreated = true;
}
}
if(file1){
fwrite(source_frame->data_ , 1, sizeof(int16_t)*source_frame->samples_per_channel_*source_frame->num_channels_, file1);
}
Ref:
1.Iphone文件读写操作
2.NULL when using fopen with xcode
网友评论