/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "ktx-loader.h"
#include "model-skybox.h"
#include "model-pbr.h"
+#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-stream.h>
using namespace Dali;
using namespace Toolkit;
*/
bool LoadShaderCode( const std::string& fullpath, std::vector<char>& output )
{
- FILE* f = fopen( fullpath.c_str(), "rb" );
-
- if( NULL == f )
+ Dali::FileStream fileStream( fullpath, FileStream::READ | FileStream::BINARY );
+ FILE* file = fileStream.GetFile();
+ if( NULL == file )
{
return false;
}
- fseek( f, 0, SEEK_END );
- size_t size = ftell( f );
- fseek( f, 0, SEEK_SET );
- output.resize( size + 1 );
- std::fill( output.begin(), output.end(), 0 );
- ssize_t result = fread( output.data(), size, 1, f );
- fclose( f );
- return ( result >= 0 );
+ bool retValue = false;
+ if( ! fseek( file, 0, SEEK_END ) )
+ {
+ long int size = ftell( file );
+
+ if( ( size != -1L ) &&
+ ( ! fseek( file, 0, SEEK_SET ) ) )
+ {
+ output.resize( size + 1 );
+ std::fill( output.begin(), output.end(), 0 );
+ ssize_t result = fread( output.data(), size, 1, file );
+
+ retValue = ( result >= 0 );
+ }
+ }
+
+ return retValue;
}
/**