@@ -134,6 +134,43 @@ function initialize_drug_events()
134
134
} ;
135
135
}
136
136
137
+ function open_filepath ( arg , errs_ ) {
138
+ if ( null === arg . open_filepath ) {
139
+ return true ;
140
+ }
141
+
142
+ console . log ( "open_filepath:" , arg . open_filepath ) ;
143
+
144
+ if ( typeof arg . open_filepath !== 'string' ) {
145
+ DaisyIO . add_errs_ ( errs_ , 'bug' , "Open" , "filepath is not string (internal error)." ) ;
146
+ return false ;
147
+ }
148
+
149
+ if ( ! / \. d a i s y .* $ / . test ( arg . open_filepath ) ) {
150
+ // 拡張子に".daisy*"を含む("*.daisysequence")
151
+
152
+ if ( / ^ - p s n _ 0 _ [ 0 - 9 ] + $ / . test ( arg . open_filepath ) ) {
153
+ // macosxで初回起動時に渡される場合のある""(ex. '-psn_0_2958034')
154
+ console . debug ( "through for macosx:" , arg . open_filepath ) ;
155
+ return true ;
156
+ }
157
+
158
+ DaisyIO . add_errs_ ( errs_ , 'warning' , "Open" , 'invalid extension (not ".daisy*").' ) ;
159
+ return false ;
160
+ }
161
+
162
+ let doc_id = daisy . open_doc_from_path ( arg . open_filepath , errs_ ) ;
163
+ if ( - 1 === doc_id ) {
164
+ console . error ( arg . open_filepath , errs_ ) ;
165
+ if ( ! arg . is_cli_mode ) {
166
+ message_dialog ( errs_ [ 0 ] . level , errs_ [ 0 ] . label , errs_ [ 0 ] . message ) ;
167
+ }
168
+ return false ;
169
+ }
170
+
171
+ return true ;
172
+ }
173
+
137
174
window . onload = function ( e ) {
138
175
default_title = document . title ;
139
176
@@ -148,20 +185,12 @@ window.onload = function(e){
148
185
daisy = new Daisy ( callback_focus_change , callback_history_change_doc ) ;
149
186
daisy . add_event_listener_current_doc_change ( callback_current_doc_change ) ;
150
187
151
- if ( null !== arg . open_filepath ) {
152
- console . log ( "open_filepath:" , arg . open_filepath ) ;
188
+ let errs_ = [ ] ;
153
189
154
- let errs_ = [ ] ;
155
- let doc_id = daisy . open_doc_from_path ( arg . open_filepath , errs_ ) ;
190
+ if ( ! open_filepath ( arg , errs_ ) ) {
156
191
for ( let i = 0 ; i < errs_ . length ; i ++ ) {
157
192
process . stderr . write ( sprintf ( "export[%2d/%2d]%8s:%s\n" , i , errs_ . length , errs_ [ i ] . level , errs_ [ i ] . message ) ) ;
158
193
}
159
- if ( - 1 === doc_id ) {
160
- console . error ( arg . open_filepath , errs_ ) ;
161
- if ( ! arg . is_cli_mode ) {
162
- message_dialog ( errs_ [ 0 ] . level , errs_ [ 0 ] . label , errs_ [ 0 ] . message ) ;
163
- }
164
- }
165
194
}
166
195
167
196
if ( null !== arg . export_filepath ) {