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 = arg.find( ".json" );
52 if( idx != std::string::npos )
58 idx = arg.find( ".js" );
59 if( idx != std::string::npos )
61 javaScriptFileName = arg;
66 if( !jSONFileName.empty() )
68 bool exists = CheckIfFileExists( jSONFileName );
71 DALI_ASSERT_ALWAYS( 0 && "JSON file not found ")
74 if( !javaScriptFileName.empty() )
76 bool exists = CheckIfFileExists( javaScriptFileName );
79 DALI_ASSERT_ALWAYS( 0 && "JavaScript file not found ")
82 if( jSONFileName.empty() && javaScriptFileName.empty() )
84 printf("Please specify a JSON and/or JavaScript file to load, e.g. scripting.example mylayout.json my-test.js\n");
89 Launcher daliApplication( Dali::Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ), jSONFileName, javaScriptFileName );
91 daliApplication.MainLoop();