$(adaptor_adaptor_ubuntu_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_ubuntu_x11_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
$(adaptor_adaptor_tizen_wayland_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_tizen_wayland_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
$(adaptor_adaptor_tizen_wayland_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_tizen_wayland_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
$(adaptor_adaptor_tizen_wayland_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_tizen_wayland_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
$(adaptor_adaptor_tizen_wayland_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_tizen_wayland_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
$(adaptor_adaptor_tizen_wearable_src_files) \
$(adaptor_clipboard_common_src_files) \
$(adaptor_clipboard_tizen_wayland_src_files) \
+ $(adaptor_framework_generic_src_files) \
$(devel_api_src_files) \
$(adaptor_devel_api_text_abstraction_src_files) \
$(adaptor_graphics_common_src_files) \
adaptor_clipboard_dir = ../../../dali/internal/clipboard
include ../../../dali/internal/clipboard/file.list
+# module: adaptor-framework
+adaptor_framework_dir = ../../../dali/internal/adaptor-framework
+include ../../../dali/internal/adaptor-framework/file.list
+
# Module: graphics
adaptor_graphics_dir = ../../../dali/internal/graphics
include ../../../dali/internal/graphics/file.list
/*
- * Copyright (c) 2015 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.
// CLASS HEADER
#include <dali/devel-api/adaptor-framework/file-loader.h>
-
+// EXTERNAL INCLUDES
#include <iostream>
#include <fstream>
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor-framework/common/file-loader-impl.h>
+
namespace Dali
{
int ReadFile(const std::string& filename, Dali::Vector<char> & memblock, FileLoader::FileType fileType)
{
- std::streampos size;
-
- return ReadFile( filename, size, memblock, fileType);
+ return Dali::Internal::Adaptor::ReadFile( filename, memblock, fileType );
}
-int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char> & memblock, FileLoader::FileType fileType)
+int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char>& memblock, FileLoader::FileType fileType)
{
- int errorCode = 0;
- std::ifstream * file;
-
-
- if( fileType == BINARY )
- {
- file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
- }
- else if( fileType == TEXT )
- {
- file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::ate);
- }
- else
- {
- return errorCode;
- }
-
- if( file->is_open() )
- {
- fileSize = file->tellg();
-
- memblock.Resize( fileSize );
-
- file->seekg (0, std::ios::beg);
- file->read( memblock.Begin(), fileSize );
- file->close();
-
- delete file;
-
- errorCode = 1;
- }
-
- return errorCode;
+ return Dali::Internal::Adaptor::ReadFile( filename, fileSize, memblock, fileType );;
}
-
std::streampos GetFileSize(const std::string& filename)
{
- std::streampos size = 0;
-
- std::ifstream file (filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
- if( file.is_open() )
- {
- size = file.tellg();
- file.close();
- }
- return size;
+ return Dali::Internal::Adaptor::GetFileSize(filename);
}
} //FileLoader
--- /dev/null
+#ifndef DALI_FILE_LOADER_IMPL_GENERIC_H
+#define DALI_FILE_LOADER_IMPL_GENERIC_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-loader.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int ReadFile(const std::string& filename, Dali::Vector<char>& memblock, Dali::FileLoader::FileType fileType = Dali::FileLoader::BINARY);
+
+int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char>& memblock, Dali::FileLoader::FileType fileType = Dali::FileLoader::BINARY);
+
+std::streampos GetFileSize(const std::string& filename);
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
+#endif // DALI_FILE_LOADER_IMPL_GENERIC_H
--- /dev/null
+# module: adaptor-framework, backend: generic
+adaptor_framework_generic_src_files=\
+ ${adaptor_framework_dir}/generic/file-loader-impl-generic.cpp
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor-framework/common/file-loader-impl.h>
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <fstream>
+
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int ReadFile(const std::string& filename, Dali::Vector<char> & memblock, Dali::FileLoader::FileType fileType)
+{
+ std::streampos size;
+
+ return Dali::Internal::Adaptor::ReadFile( filename, size, memblock, fileType);
+}
+
+int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char> & memblock, Dali::FileLoader::FileType fileType)
+{
+ int errorCode = 0;
+ std::ifstream * file;
+
+ if( fileType == Dali::FileLoader::BINARY )
+ {
+ file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
+ }
+ else if( fileType == Dali::FileLoader::TEXT )
+ {
+ file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::ate);
+ }
+ else
+ {
+ return errorCode;
+ }
+
+ if( file->is_open() )
+ {
+ fileSize = file->tellg();
+
+ memblock.Resize( fileSize );
+
+ file->seekg (0, std::ios::beg);
+ file->read( memblock.Begin(), fileSize );
+ file->close();
+
+ delete file;
+
+ errorCode = 1;
+ }
+ else
+ {
+ DALI_LOG_WARNING( "file open failed for: \"%s\"", filename );
+ }
+
+ return errorCode;
+}
+
+std::streampos GetFileSize(const std::string& filename)
+{
+ std::streampos size = 0;
+
+ std::ifstream file( filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate );
+ if( file.is_open() )
+ {
+ size = file.tellg();
+ file.close();
+ }
+
+ return size;
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
/*
- * Copyright (c) 2014 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 <dali/internal/haptics/common/feedback-player-impl.h>
// EXTERNAL INCLUDES
-#include <fstream>
#include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
+#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali/internal/system/common/singleton-service-impl.h>
{
bool loaded = false;
- std::ifstream stream(filename.c_str());
-
- if( stream.is_open() )
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::TEXT ) )
{
- data.assign((std::istreambuf_iterator<char>(stream)),
- std::istreambuf_iterator<char>());
+ data.assign( &fileBuffer[0], bufferSize );
loaded = true;
}
#include <dali/internal/styling/common/style-monitor-impl.h>
// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/public-api/object/type-registry.h>
-#include <fstream>
-#include <sstream>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output )
{
bool retval( false );
- std::ifstream in( filename.c_str(), std::ios::in );
- if( in )
- {
- std::stringstream buffer;
- buffer << in.rdbuf();
-
- output = buffer.str();
- in.close();
+ std::streampos bufferSize = 0;
+ Dali::Vector<char> fileBuffer;
+ if( Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::TEXT ) )
+ {
+ output.assign( &fileBuffer[0], bufferSize );
retval = true;
}
+
return retval;
}
*/
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-loader.h>
// EXTERNAL INCLUDES
#include <cstdio>
/**
* @brief Construct a FileCloser guarding a new FILE* for accessing the path passed in.
*/
- FileCloser( const char * const filename, const char * const mode )
- : mFile(fopen(filename, mode))
+ FileCloser( const char* const filename, const char* const mode )
{
- DALI_ASSERT_DEBUG( filename != 0 && "Cant open a null filename." );
+ DALI_ASSERT_DEBUG( filename != 0 && "Can't open a null filename." );
DALI_ASSERT_DEBUG( mode != 0 && "Null mode is undefined behaviour in spec." );
- if( mFile == 0 )
+ Dali::FileLoader::FileType fileType = Dali::FileLoader::FileType::TEXT;
+
+ const char* modeStr = mode;
+ while( *modeStr )
+ {
+ switch ( *modeStr )
+ {
+ case 'r':
+ break;
+ case 'b':
+ fileType = FileLoader::FileType::BINARY;
+ break;
+ // Still has to use fopen for append and write modes
+ case 'a':
+ case 'w':
+ case '+':
+ mFile = fopen( filename, mode );
+ return;
+ default:
+ break;
+ }
+
+ ++modeStr;
+ }
+
+ std::streampos bufferSize = 0;
+ if( !Dali::FileLoader::ReadFile( filename, bufferSize, mFileBuffer, fileType ) )
+ {
+ mFile = nullptr;
+ }
+ else
{
- DALI_LOG_WARNING( "File open failed for: \"%s\" in mode: \"%s\".\n", filename, mode );
+ mFile = fmemopen( &mFileBuffer[0], bufferSize, mode );
}
}
/**
* @brief Construct a FileCloser guarding a FILE* for reading out of the memory buffer passed in.
*/
- FileCloser( uint8_t* buffer, size_t dataSize, const char * const mode )
+ FileCloser( uint8_t* buffer, size_t dataSize, const char* const mode )
: mFile( fmemopen( buffer, dataSize, mode) )
{
}
private:
FILE* mFile;
+ Dali::Vector<char> mFileBuffer;
};
} // namespace Platform