327 export_prune: Int = 0, |
327 export_prune: Int = 0, |
328 export_list: Boolean = false, |
328 export_list: Boolean = false, |
329 export_patterns: List[String] = Nil |
329 export_patterns: List[String] = Nil |
330 ): Unit = { |
330 ): Unit = { |
331 using(store.open_database(session_name)) { db => |
331 using(store.open_database(session_name)) { db => |
332 db.transaction { |
332 val entry_names = read_entry_names(db, session_name) |
333 val entry_names = read_entry_names(db, session_name) |
333 |
334 |
334 // list |
335 // list |
335 if (export_list) { |
336 if (export_list) { |
336 for (entry_name <- entry_names) progress.echo(entry_name.compound_name) |
337 for (entry_name <- entry_names) progress.echo(entry_name.compound_name) |
337 } |
338 } |
338 |
339 |
339 // export |
340 // export |
340 if (export_patterns.nonEmpty) { |
341 if (export_patterns.nonEmpty) { |
341 val matcher = make_matcher(export_patterns) |
342 val matcher = make_matcher(export_patterns) |
342 for { |
343 for { |
343 entry_name <- entry_names if matcher(entry_name) |
344 entry_name <- entry_names if matcher(entry_name) |
344 entry <- entry_name.read(db, store.cache) |
345 entry <- entry_name.read(db, store.cache) |
345 } { |
346 } { |
346 val path = export_dir + entry_name.make_path(prune = export_prune) |
347 val path = export_dir + entry_name.make_path(prune = export_prune) |
347 progress.echo("export " + path + (if (entry.executable) " (executable)" else "")) |
348 progress.echo("export " + path + (if (entry.executable) " (executable)" else "")) |
348 Isabelle_System.make_directory(path.dir) |
349 Isabelle_System.make_directory(path.dir) |
349 val bytes = entry.uncompressed |
350 val bytes = entry.uncompressed |
350 if (!path.is_file || Bytes.read(path) != bytes) Bytes.write(path, bytes) |
351 if (!path.is_file || Bytes.read(path) != bytes) Bytes.write(path, bytes) |
351 File.set_executable(path, entry.executable) |
352 File.set_executable(path, entry.executable) |
|
353 } |
|
354 } |
352 } |
355 } |
353 } |
356 } |
354 } |
357 } |
355 } |
358 |
356 |