summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builder/dali-builder.cpp13
-rw-r--r--examples/builder/examples.cpp12
-rw-r--r--examples/fpp-game/game-utils.cpp13
-rw-r--r--examples/ray-marching/ray-marching-example.cpp10
-rw-r--r--examples/refraction-effect/refraction-effect-example.cpp19
-rw-r--r--examples/rendering-basic-pbr/ktx-loader.cpp12
-rw-r--r--examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp14
-rw-r--r--examples/simple-text-renderer/simple-text-renderer-example.cpp3
8 files changed, 73 insertions, 23 deletions
diff --git a/builder/dali-builder.cpp b/builder/dali-builder.cpp
index 4481c3d5..5445fd19 100644
--- a/builder/dali-builder.cpp
+++ b/builder/dali-builder.cpp
@@ -27,6 +27,7 @@
//------------------------------------------------------------------------------
#include <dali/dali.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/builder/builder.h>
#include <dali-toolkit/devel-api/builder/tree-node.h>
@@ -102,10 +103,16 @@ private:
std::time_t mLastTime;
std::string mstringPath;
- std::string GetFileContents(const std::string &fn)
+ std::string GetFileContents(const std::string &filename)
{
- std::ifstream t(fn.c_str());
- return std::string((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+ {
+ return std::string();
+ }
+
+ return std::string( &fileBuffer[0], bufferSize );
};
};
diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp
index ba47e289..e0222277 100644
--- a/examples/builder/examples.cpp
+++ b/examples/builder/examples.cpp
@@ -43,6 +43,7 @@
#include <cstring>
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include "shared/view.h"
#define TOKEN_STRING(x) #x
@@ -86,9 +87,14 @@ std::string ReplaceQuotes(const std::string &single_quoted)
std::string GetFileContents(const std::string &fn)
{
- std::ifstream t(fn.c_str());
- return std::string((std::istreambuf_iterator<char>(t)),
- std::istreambuf_iterator<char>());
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( fn, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+ {
+ return std::string();
+ }
+
+ return std::string( &fileBuffer[0], bufferSize );
};
typedef std::vector<std::string> FileList;
diff --git a/examples/fpp-game/game-utils.cpp b/examples/fpp-game/game-utils.cpp
index 8cb99f10..12ac0019 100644
--- a/examples/fpp-game/game-utils.cpp
+++ b/examples/fpp-game/game-utils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 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.
@@ -17,6 +17,8 @@
#include <inttypes.h>
#include <stdio.h>
+#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include "game-utils.h"
@@ -24,7 +26,14 @@ namespace GameUtils
{
bool LoadFile( const char* filename, ByteArray& bytes )
{
- FILE* fin = fopen( filename, "rb" );
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, Dali::FileLoader::FileType::BINARY ) )
+ {
+ return false;
+ }
+
+ FILE* fin = fmemopen( &fileBuffer[0], bufferSize, "rb" );
if( fin )
{
if( fseek( fin, 0, SEEK_END ) )
diff --git a/examples/ray-marching/ray-marching-example.cpp b/examples/ray-marching/ray-marching-example.cpp
index d6382173..4a6f7a30 100644
--- a/examples/ray-marching/ray-marching-example.cpp
+++ b/examples/ray-marching/ray-marching-example.cpp
@@ -20,6 +20,8 @@
#include "shared/view.h"
#include "shared/utility.h"
#include <stdio.h>
+#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
using namespace Dali;
using Dali::Toolkit::TextLabel;
@@ -41,12 +43,16 @@ bool LoadShaderCode( const char* path, const char* filename, std::vector<char>&
{
std::string fullpath( path );
fullpath += filename;
- FILE* file = fopen( fullpath.c_str(), "rb" );
- if( ! file )
+
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( fullpath, bufferSize, fileBuffer, Dali::FileLoader::FileType::BINARY ) )
{
return false;
}
+ FILE* file = fmemopen( &fileBuffer[0], bufferSize, "rb" );
+
bool retValue = false;
if( ! fseek( file, 0, SEEK_END ) )
{
diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp
index 14c4878c..ffbc59a3 100644
--- a/examples/refraction-effect/refraction-effect-example.cpp
+++ b/examples/refraction-effect/refraction-effect-example.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -19,8 +19,9 @@
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
-#include <fstream>
#include <sstream>
#include <limits>
@@ -471,14 +472,22 @@ private:
std::vector<Vector3>& vertexPositions,
Vector<unsigned int>& faceIndices)
{
- std::ifstream ifs( objFileName.c_str(), std::ios::in );
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( objFileName, bufferSize, fileBuffer, Dali::FileLoader::FileType::TEXT ) )
+ {
+ DALI_LOG_WARNING( "file open failed for: \"%s\"", objFileName );
+ return;
+ }
+
+ std::stringstream iss( &fileBuffer[0], std::ios::in );
boundingBox.Resize( 6 );
boundingBox[0]=boundingBox[2]=boundingBox[4] = std::numeric_limits<float>::max();
boundingBox[1]=boundingBox[3]=boundingBox[5] = -std::numeric_limits<float>::max();
std::string line;
- while( std::getline( ifs, line ) )
+ while( std::getline( iss, line ) )
{
if( line[0] == 'v' && std::isspace(line[1])) // vertex
{
@@ -518,8 +527,6 @@ private:
faceIndices.PushBack( indices[2*step]-1 );
}
}
-
- ifs.close();
}
void ShapeResizeAndTexureCoordinateCalculation( const Vector<float>& boundingBox,
diff --git a/examples/rendering-basic-pbr/ktx-loader.cpp b/examples/rendering-basic-pbr/ktx-loader.cpp
index 175d6c3a..627d74bf 100644
--- a/examples/rendering-basic-pbr/ktx-loader.cpp
+++ b/examples/rendering-basic-pbr/ktx-loader.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -22,6 +22,8 @@
#include <memory.h>
#include <stdio.h>
#include <stdint.h>
+#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
namespace PbrDemo
{
@@ -92,8 +94,14 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form
bool LoadCubeMapFromKtxFile( const std::string& path, CubeData& cubedata )
{
- FILE* fp = fopen(path.c_str(),"rb");
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( path, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+ {
+ return false;
+ }
+ FILE* fp = fmemopen( &fileBuffer[0], bufferSize, "rb" );
if( NULL == fp )
{
return false;
diff --git a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp
index 931f5fbd..9d2a9d1e 100644
--- a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp
+++ b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -25,6 +25,8 @@
#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-loader.h>
using namespace Dali;
using namespace Toolkit;
@@ -390,7 +392,15 @@ public:
*/
bool LoadShaderCode( const std::string& fullpath, std::vector<char>& output )
{
- FILE* file = fopen( fullpath.c_str(), "rb" );
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( !Dali::FileLoader::ReadFile( fullpath, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+ {
+ DALI_LOG_WARNING( "file open failed for: \"%s\"", path );
+ return false;
+ }
+
+ FILE* file = fmemopen( &fileBuffer[0], bufferSize, "rb" );
if( NULL == file )
{
return false;
diff --git a/examples/simple-text-renderer/simple-text-renderer-example.cpp b/examples/simple-text-renderer/simple-text-renderer-example.cpp
index 3f8116f6..c980170c 100644
--- a/examples/simple-text-renderer/simple-text-renderer-example.cpp
+++ b/examples/simple-text-renderer/simple-text-renderer-example.cpp
@@ -26,9 +26,6 @@
#include <dali-toolkit/devel-api/text/text-utils-devel.h>
#include <devel-api/adaptor-framework/image-loading.h>
-#include <iostream>
-#include <fstream>
-
using namespace std;
using namespace Dali;
using namespace Dali::Toolkit;