Merge pull request #7675 from darkdukey/chore/reuse-file-utils-for-video-path

Chore/reuse file utils for video path
This commit is contained in:
minggo 2014-08-06 09:41:28 +08:00
commit 16653bf24e
1 changed files with 2 additions and 17 deletions

View File

@ -31,6 +31,7 @@ using namespace cocos2d::experimental::ui;
#include "CCEAGLView.h"
#import <MediaPlayer/MediaPlayer.h>
#include "base/CCDirector.h"
#include "CCFileUtils.h"
@interface UIVideoViewWrapperIos : NSObject
@ -259,23 +260,7 @@ using namespace cocos2d::experimental::ui;
+(NSString*) fullPathFromRelativePath:(NSString*) relPath
{
// do not convert an absolute path (starting with '/')
if(([relPath length] > 0) && ([relPath characterAtIndex:0] == '/'))
{
return relPath;
}
NSMutableArray *imagePathComponents = [NSMutableArray arrayWithArray:[relPath pathComponents]];
NSString *file = [imagePathComponents lastObject];
[imagePathComponents removeLastObject];
NSString *imageDirectory = [NSString pathWithComponents:imagePathComponents];
NSString *fullpath = [[NSBundle mainBundle] pathForResource:file ofType:nil inDirectory:imageDirectory];
if (fullpath == nil)
fullpath = relPath;
return fullpath;
return [NSString stringWithCString: cocos2d::FileUtils::getInstance()->fullPathForFilename(std::string([relPath UTF8String])).c_str() encoding: [NSString defaultCStringEncoding]];
}
@end
//------------------------------------------------------------------------------------------------------------