2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/integration-api/debug.h>
29 bool CheckIfFileExists( const std::string& filename )
32 // fstat returns -1 on error
33 if (stat( filename.c_str(), &buf) != -1)
41 int main( int argc, char* argv[] )
43 // pull out the JSON file and JavaScript file from the command line arguments
44 std::string javaScriptFileName;
45 std::string jSONFileName;
47 for( int i = 1 ; i < argc ; ++i )
49 std::string arg( argv[i] );
51 size_t idx = std::string::npos;
53 idx = arg.find( ".json" );
54 if( idx != std::string::npos )
60 idx = arg.find( ".js" );
61 if( idx != std::string::npos )
63 javaScriptFileName = arg;
68 if( !jSONFileName.empty() )
70 bool exists = CheckIfFileExists( jSONFileName );
73 DALI_ASSERT_ALWAYS( 0 && "JSON file not found ")
76 if( !javaScriptFileName.empty() )
78 bool exists = CheckIfFileExists( javaScriptFileName );
81 DALI_ASSERT_ALWAYS( 0 && "JavaScript file not found ")
84 if( jSONFileName.empty() && javaScriptFileName.empty() )
86 printf("Please specify a JSON and/or JavaScript file to load, e.g. scripting.example mylayout.json my-test.js\n");
91 Launcher daliApplication( Dali::Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ), jSONFileName, javaScriptFileName );
93 daliApplication.MainLoop();