diff options
Diffstat (limited to 'src/files.php')
-rw-r--r-- | src/files.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/files.php b/src/files.php new file mode 100644 index 0000000..9e1a3f5 --- /dev/null +++ b/src/files.php | |||
@@ -0,0 +1,38 @@ | |||
1 | <?php | ||
2 | // src/files.php | ||
3 | // | ||
4 | // fonctions pour manipuler les fichiers latex et pdf | ||
5 | |||
6 | function makeFile($path, $file_name, $data) | ||
7 | { | ||
8 | file_put_contents($path. $file_name, $data); | ||
9 | chmod($path . $file_name, 0644); // droits en octal | ||
10 | } | ||
11 | |||
12 | function makeFolder(string $path) | ||
13 | { | ||
14 | if(!file_exists($path)) | ||
15 | { | ||
16 | mkdir($path); | ||
17 | chmod($path, 0755); // droits en octal | ||
18 | } | ||
19 | } | ||
20 | |||
21 | // commande système pdflatex | ||
22 | function latexToPdf(string $latex_path, string $file_name, string $pdf_path) | ||
23 | { | ||
24 | $output_dir = ''; | ||
25 | if($pdf_path !== '') | ||
26 | { | ||
27 | $output_dir = '-output-directory=' . $pdf_path . ' '; | ||
28 | } | ||
29 | |||
30 | // compilation | ||
31 | //echo 'pdflatex ' . $output_dir . $latex_path . $file_name . "\n"; | ||
32 | exec('pdflatex ' . $output_dir . $latex_path . $file_name); | ||
33 | |||
34 | // nettoyage | ||
35 | $basename = basename($file_name, '.tex'); | ||
36 | unlink($pdf_path . $basename . '.aux'); | ||
37 | unlink($pdf_path . $basename . '.log'); | ||
38 | } | ||