Debian Codegraph @

doc/mz_os.md

raw symbols SCIP
1 # MZ_OS <!-- omit in toc -->
2
3 These functions provide support for handling common file system operations.
4
5 - [Path](#path)
6 - [mz_path_combine](#mz_path_combine)
7 - [mz_path_append_slash](#mz_path_append_slash)
8 - [mz_path_remove_slash](#mz_path_remove_slash)
9 - [mz_path_has_slash](#mz_path_has_slash)
10 - [mz_path_convert_slashes](#mz_path_convert_slashes)
11 - [mz_path_compare_wc](#mz_path_compare_wc)
12 - [mz_path_resolve](#mz_path_resolve)
13 - [mz_path_remove_filename](#mz_path_remove_filename)
14 - [mz_path_remove_extension](#mz_path_remove_extension)
15 - [mz_path_get_filename](#mz_path_get_filename)
16 - [Directory](#directory)
17 - [mz_dir_make](#mz_dir_make)
18 - [File](#file)
19 - [mz_file_get_crc](#mz_file_get_crc)
20 - [Operating System](#operating-system)
21 - [mz_os_unicode_string_create](#mz_os_unicode_string_create)
22 - [mz_os_unicode_string_delete](#mz_os_unicode_string_delete)
23 - [mz_os_utf8_string_create](#mz_os_utf8_string_create)
24 - [mz_os_utf8_string_delete](#mz_os_utf8_string_delete)
25 - [mz_os_rand](#mz_os_rand)
26 - [mz_os_rename](#mz_os_rename)
27 - [mz_os_unlink](#mz_os_unlink)
28 - [mz_os_file_exists](#mz_os_file_exists)
29 - [mz_os_get_file_size](#mz_os_get_file_size)
30 - [mz_os_get_file_date](#mz_os_get_file_date)
31 - [mz_os_set_file_date](#mz_os_set_file_date)
32 - [mz_os_get_file_attribs](#mz_os_get_file_attribs)
33 - [mz_os_set_file_attribs](#mz_os_set_file_attribs)
34 - [mz_os_make_dir](#mz_os_make_dir)
35 - [mz_os_open_dir](#mz_os_open_dir)
36 - [mz_os_read_dir](#mz_os_read_dir)
37 - [mz_os_close_dir](#mz_os_close_dir)
38 - [mz_os_is_dir](#mz_os_is_dir)
39 - [mz_os_is_symlink](#mz_os_is_symlink)
40 - [mz_os_make_symlink](#mz_os_make_symlink)
41 - [mz_os_read_symlink](#mz_os_read_symlink)
42 - [mz_os_ms_time](#mz_os_ms_time)
43
44 ## Path
45
46 The _mz_path_ family of functions are helper functions used when constructing file system paths.
47
48 ### mz_path_combine
49
50 Combines two paths.
51
52 **Arguments**
53 |Type|Name|Description|
54 |-|-|-|
55 |char *|path|Base path|
56 |const char *|join|Path to append|
57 |int32_t|max_path|Maximum path buffer size|
58
59 **Return**
60 |Type|Description|
61 |-|-|
62 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
63
64 **Example**
65 ```
66 char path[120];
67 strncat(path, "c:\\windows\\", sizeof(path));
68 mz_path_combine(path, "temp", sizeof(path));
69 printf("Combined path: %s\n", path);
70 ```
71
72 ### mz_path_append_slash
73
74 Appends a path slash on to the end of the path. To get the path slash character for the compiler platform use _MZ_PATH_SLASH_PLATFORM_ preprocessor define.
75
76 **Arguments**
77 |Type|Name|Description|
78 |-|-|-|
79 |char *|path|Path|
80 |int32_t|max_path|Maximum bytes to store path|
81 |char|slash|Path slash character|
82
83 **Return**
84 |Type|Description|
85 |-|-|
86 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
87
88 **Example**
89 ```
90 char path[120];
91 strncat(path, "c:\\windows", sizeof(path));
92 mz_path_append_slash(path, sizeof(path), MZ_PATH_SLASH_PLATFORM);
93 printf("Path with end slash: %s\n", path);
94 ```
95
96 ### mz_path_remove_slash
97
98 Removes a path slash from the end of the path.
99
100 **Arguments**
101 |Type|Name|Description|
102 |-|-|-|
103 |char *|path|Path|
104
105 **Return**
106 |Type|Description|
107 |-|-|
108 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
109
110 **Example**
111 ```
112 char path[120];
113 strncat(path, "c:\\windows\\", sizeof(path));
114 mz_path_remove_slash(path);
115 printf("Path with no slash: %s\n", path);
116 ```
117
118 ### mz_path_has_slash
119
120 Returns whether or not the path ends with slash.
121
122 **Arguments**
123 |Type|Name|Description|
124 |-|-|-|
125 |const char *|path|Path|
126
127 **Return**
128 |Type|Description|
129 |-|-|
130 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if has slash.|
131
132 **Example**
133 ```
134 const char *path = "c:\\windows\\";
135 if (mz_path_has_slash(path) == MZ_OK)
136 printf("Path ends with a slash\n");
137 else
138 printf("Path does not end with a slash\n");
139 ```
140
141 ### mz_path_convert_slashes
142
143 Converts the slashes in a path. This can be used to convert all unix path slashes to windows path slashes or conver all windows path slashes to unix path slashes. If there are mixed slashes in the path, it can unify them to all one format.
144
145 **Arguments**
146 |Type|Name|Description|
147 |-|-|-|
148 |char *|path|Path|
149 |char|slash|Path slash character|
150
151 **Return**
152 |Type|Description|
153 |-|-|
154 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if has slash.|
155
156 **Example**
157 ```
158 char path[120];
159 strncat(path, "c:\\windows\\", sizeof(path));
160 if (mz_path_convert_slashes(path, MZ_PATH_SLASH_UNIX) == MZ_OK)
161 printf("Path converted to unix slashes: %s\n", path);
162 ```
163
164 ### mz_path_compare_wc
165
166 Compares two paths with a wildcard.
167
168 **Arguments**
169 |Type|Name|Description|
170 |-|-|-|
171 |const char *|path|Path|
172 |const char *|wildcard|Wildcard pattern|
173 |uint8_t|ignore_case|Ignore case during comparison if 1.|
174
175 **Return**
176 |Type|Description|
177 |-|-|
178 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if matched, MZ_EXIST_ERROR if not matched.|
179
180 **Example**
181 ```
182 const char *path = "test.txt";
183 if (mz_path_compare_wc(path, "*.txt", 0) == MZ_OK)
184 printf("%s is a text file\n", path);
185 else
186 printf("%s is not a text file\n", path);
187 ```
188
189 ### mz_path_resolve
190
191 Resolves a path. Path parts that only contain dots will be resolved. If a path part contains a single dot, it will be remoed. If a path part contains two dots, it will remove the last path part. This function can be used to prevent the _zipslip_ vulnerability and ensure that files are not written outside of their intended target.
192
193 **Arguments**
194 |Type|Name|Description|
195 |-|-|-|
196 |const char *|path|Path|
197 |char *|target|Resolved path character array|
198 |int32_t|max_target|Maximum size of resolved path array|
199
200 **Return**
201 |Type|Description|
202 |-|-|
203 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
204
205 **Example**
206 ```
207 const char *path = "c:\\windows\\..\\";
208 char target[120];
209 mz_path_resolve(path, target, sizeof(target));
210 printf("Resolved path: %s\n", target);
211 ```
212
213 ### mz_path_remove_filename
214
215 Removes the filename from a path.
216
217 **Arguments**
218 |Type|Name|Description|
219 |-|-|-|
220 |char *|path|Path|
221
222 **Return**
223 |Type|Description|
224 |-|-|
225 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
226
227 **Example**
228 ```
229 char path[120];
230 strncpy(path, "c:\\windows\\test.txt", sizeof(path));
231 printf("Path: %s\n", path);
232 mz_path_remove_filename(path);
233 printf("Path with no filename: %s\n", path);
234 ```
235
236 ### mz_path_remove_extension
237
238 Remove the extension from a path.
239
240 **Arguments**
241 |Type|Name|Description|
242 |-|-|-|
243 |char *|path|Path|
244
245 **Return**
246 |Type|Description|
247 |-|-|
248 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
249
250 **Example**
251 ```
252 char path[120];
253 strncpy(path, "c:\\windows\\test.txt", sizeof(path));
254 printf("Path: %s\n", path);
255 mz_path_remove_extension(path);
256 printf("Path with no file extension: %s\n", path);
257 ```
258
259 ### mz_path_get_filename
260
261 Get the filename from a path.
262
263 **Arguments**
264 |Type|Name|Description|
265 |-|-|-|
266 |const char *|path|Path|
267 |const char **|filename|Pointer to filename string|
268
269 **Return**
270 |Type|Description|
271 |-|-|
272 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
273
274 **Example**
275 ```
276 const char *path = "c:\\windows\\test.txt";
277 const char *filename = NULL;
278 printf("Path: %s\n", path);
279 if (mz_path_get_filename(path, &filename) == MZ_OK)
280 printf("Filename: %s\n", filename);
281 else
282 printf("Path has no filename\n");
283 ```
284
285 ## Directory
286
287 ### mz_dir_make
288
289 Creates a directory recursively.
290
291 **Arguments**
292 |Type|Name|Description|
293 |-|-|-|
294 |const char *|path|Path|
295
296 **Return**
297 |Type|Description|
298 |-|-|
299 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
300
301 **Example**
302 ```
303 const char *path = "c:\\temp\\x\\y\\z\\";
304 if (mz_dir_make(path) == MZ_OK)
305 printf("Dir was created: %s\n", path);
306 else
307 printf("Dir was not created: %s\n", path);
308 ```
309
310 ## File
311
312 ### mz_file_get_crc
313
314 Gets the crc32 hash of a file. This function helps provide functional backwards compatibility.
315
316 **Arguments**
317 |Type|Name|Description|
318 |-|-|-|
319 |const char *|path|Path to calculate CRC value for|
320 |uint32_t *|result_crc|Pointer to store the calculated CRC value|
321
322 **Return**
323 |Type|Description|
324 |-|-|
325 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
326
327 **Example**
328 ```
329 const char *path = "c:\\temp\\test.txt";
330 uint32_t crc = 0;
331 if (mz_file_get_crc(path, &crc) == MZ_OK)
332 printf("File %s CRC: %08x\n", path, crc);
333 else
334 printf("Failed to calculate CRC: %s\n", path);
335 ```
336
337 ## Operating System
338
339 The _mz_os_ family of functions wrap all platform specific code necessary to zip and unzip files.
340
341 ### mz_os_unicode_string_create
342
343 Create unicode string from a string with another encoding.
344
345 **Arguments**
346 |Type|Name|Description|
347 |-|-|-|
348 |const char *|string|String to convert|
349 |int32_t|encoding|String encoding (See [MZ_ENCODING](mz_encoding.md))|
350
351 **Return**
352 |Type|Description|
353 |-|-|
354 |wchar_t *|Returns pointer to unicode string if successful, otherwise NULL.|
355
356 **Example**
357 ```
358 char *test = "test";
359 wchar_t *test_unicode = mz_os_unicode_string_create(test, MZ_ENCODING_UTF8);
360 if (test_unicode) {
361 printf("Unicode test string created\n");
362 mz_os_unicode_string_delete(&test_unicode);
363 }
364 ```
365
366 ### mz_os_unicode_string_delete
367
368 Delete a unicode string that was created with _mz_os_unicode_string_create_.
369
370 **Arguments**
371 |Type|Name|Description|
372 |-|-|-|
373 |wchar_t **|string|Pointer to unicode string|
374
375 **Example**
376 ```
377 char *test = "test";
378 wchar_t *test_unicode = mz_os_unicode_string_create(test, MZ_ENCODING_UTF8);
379 if (test_unicode) {
380 printf("Unicode test string created\n");
381 mz_os_unicode_string_delete(&test_unicode);
382 }
383 ```
384
385 ### mz_os_utf8_string_create
386
387 Create a utf8 string from a string with another encoding.
388
389 **Arguments**
390 |Type|Name|Description|
391 |-|-|-|
392 |const char *|string|String to convert|
393 |int32_t|encoding|String encoding (See [MZ_ENCODING](mz_encoding.md))|
394
395 **Return**
396 |Type|Description|
397 |-|-|
398 |char *|Returns pointer to UTF-8 encoded string if successful, otherwise NULL.|
399
400 **Example**
401 ```
402 char *test = "test";
403 char *test_utf8 = mz_os_utf8_string_create(test, MZ_ENCODING_CODEPAGE_437);
404 if (test_utf8) {
405 printf("UTF-8 test string created\n");
406 mz_os_utf8_string_delete(&test_utf8);
407 }
408 ```
409
410 ### mz_os_utf8_string_delete
411
412 Delete a utf8 string that was created with _mz_os_utf8_string_create_.
413
414 **Arguments**
415 |Type|Name|Description|
416 |-|-|-|
417 |char **|string|Pointer to utf8 encoded string|
418
419 **Example**
420 ```
421 char *test = "test";
422 char *test_utf8 = mz_os_utf8_string_create(test, MZ_ENCODING_CODEPAGE_437);
423 if (test_utf8) {
424 printf("UTF-8 test string created\n");
425 mz_os_utf8_string_delete(&test_utf8);
426 }
427 ```
428
429 ### mz_os_rand
430
431 Random number generator (not cryptographically secure). For a cryptographically secure random number generator use _mz_crypt_rand_.
432
433 **Arguments**
434 |Type|Name|Description|
435 |-|-|-|
436 |uint8_t *|buf|Buffer to fill with random data|
437 |int32_t|size|Maximum size of buffer array|
438
439 **Return**
440 |Type|Description|
441 |-|-|
442 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
443
444 **Example**
445 ```
446 uint8_t buf[120];
447 if (mz_os_rand(buf, sizeof(buf)) == MZ_OK)
448 printf("%d bytes of random data generated\n", sizeof(buf));
449 ```
450
451 ### mz_os_rename
452
453 Rename a file.
454
455 **Arguments**
456 |Type|Name|Description|
457 |-|-|-|
458 |const char *|source_path|Original path|
459 |const char *|target_path|New path|
460
461 **Return**
462 |Type|Description|
463 |-|-|
464 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
465
466 **Example**
467 ```
468 if (mz_os_rename("c:\\test1.txt", "c:\\test2.txt") == MZ_OK)
469 printf("File was renamed successfully\n");
470 ```
471
472 ### mz_os_unlink
473
474 Delete an existing file.
475
476 **Arguments**
477 |Type|Name|Description|
478 |-|-|-|
479 |const char *|path|File path|
480
481 **Return**
482 |Type|Description|
483 |-|-|
484 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
485
486 **Example**
487 ```
488 if (mz_os_unlink("c:\\test2.txt") == MZ_OK)
489 printf("File was deleted successfully\n");
490 ```
491
492 ### mz_os_file_exists
493
494 Check to see if a file exists.
495
496 **Arguments**
497 |Type|Name|Description|
498 |-|-|-|
499 |const char *|path|File path|
500
501 **Return**
502 |Type|Description|
503 |-|-|
504 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
505
506 **Example**
507 ```
508 const char *path = "c:\\test2.txt";
509 if (mz_os_file_exists(path) == MZ_OK)
510 printf("File %s exists\n", path);
511 else
512 printf("File %s does not exist\n", path);
513 ```
514
515 ### mz_os_get_file_size
516
517 Gets the length of a file.
518
519 **Arguments**
520 |Type|Name|Description|
521 |-|-|-|
522 |const char *|path|File path|
523
524 **Return**
525 |Type|Description|
526 |-|-|
527 |int64_t|Size of file, does not check for existence of file.|
528
529 **Example**
530 ```
531 const char *path = "c:\\test3.txt";
532 if (mz_os_file_exists(path) == MZ_OK) {
533 int64_t file_size = mz_os_get_file_size(path);
534 printf("File %s size %lld\n", path, file_size);
535 } else {
536 printf("File %s does not exist\n", path);
537 }
538 ```
539
540 ### mz_os_get_file_date
541
542 Gets a file's modified, access, and creation dates if supported. Creation date is not supported on Linux based systems and zero is returned for _creation_date_ on those systems.
543
544 **Arguments**
545 |Type|Name|Description|
546 |-|-|-|
547 |const char *|path|File path|
548 |time_t *|modified_date|Pointer to store file's modified unix timestamp|
549 |time_t *|accessed_date|Pointer to store file's accessed unix timestamp|
550 |time_t *|creation_date|Pointer to store file's creation unix timestamp|
551
552 **Return**
553 |Type|Description|
554 |-|-|
555 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
556
557 **Example**
558 ```
559 const char *path = "c:\\test4.txt";
560 time_t modified_date, accessed_date, creation_date;
561 if (mz_os_get_file_date(path, &modified_date, &accessed_date, &creation_date) == MZ_OK)
562 printf("File %s modified %lld accessed %lld creation %lld\n", path, modified_date, accessed_date, creation_date);
563 ```
564
565 ### mz_os_set_file_date
566
567 Sets a file's modified, access, and creation dates if supported. Creation date is not supported on Linux based systems.
568
569 **Arguments**
570 |Type|Name|Description|
571 |-|-|-|
572 |const char *|path|File path|
573 |time_t|modified_date|File's modified unix timestamp|
574 |time_t|accessed_date|File's accessed unix timestamp|
575 |time_t|creation_date|File's creation unix timestamp|
576
577 **Return**
578 |Type|Description|
579 |-|-|
580 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
581
582 **Example**
583 ```
584 const char *src_path = "c:\\test4.txt";
585 const char *target_path = "c:\\test5.txt";
586 time_t modified_date, accessed_date, creation_date;
587 if (mz_os_get_file_date(src_path, &modified_date, &accessed_date, &creation_date) == MZ_OK) {
588 printf("Source file %s modified %lld accessed %lld creation %lld\n", path, modified_date, accessed_date, creation_date);
589 if (mz_os_set_file_date(target_path, modified_date, accessed_date, creation_date) == MZ_OK) {
590 printf("Target file dates changed successfully\n");
591 }
592 }
593 ```
594
595 ### mz_os_get_file_attribs
596
597 Gets a file's attributes.
598
599 **Arguments**
600 |Type|Name|Description|
601 |-|-|-|
602 |const char *|path|File path|
603 |uint32_t *|attributes|Pointer to store file attributes value|
604
605 **Return**
606 |Type|Description|
607 |-|-|
608 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
609
610 **Example**
611 ```
612 const char *path = "c:\\test6.txt";
613 uint32_t attributes = 0;
614 if (mz_os_get_file_attribs(path, &attributes) == MZ_OK)
615 printf("File %s attributes %08x\n", attributes);
616 ```
617
618 ### mz_os_set_file_attribs
619
620 Sets a file's attributes.
621
622 **Arguments**
623 |Type|Name|Description|
624 |-|-|-|
625 |const char *|path|File path|
626 |uint32_t|attributes|File attributes value|
627
628 **Return**
629 |Type|Description|
630 |-|-|
631 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
632
633 **Example**
634 ```
635 const char *path = "c:\\test6.txt";
636 uint32_t attributes = 0;
637 if (mz_os_get_file_attribs(path, &attributes) == MZ_OK) {
638 printf("File %s attributes %08x\n", attributes);
639 attributes |= FILE_ATTRIBUTE_READONLY;
640 if (mz_os_set_file_attribs(path, attributes) == MZ_OK) {
641 printf("File changed to readonly\n");
642 }
643 }
644 ```
645
646 ### mz_os_make_dir
647
648 Creates a directory. To recursively create a directory use _mz_dir_make_.
649
650 **Arguments**
651 |Type|Name|Description|
652 |-|-|-|
653 |const char *|path|Directory path|
654
655 **Return**
656 |Type|Description|
657 |-|-|
658 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
659
660 **Example**
661 ```
662 if (mz_os_make_dir("c:\\testdir\\") == MZ_OK)
663 printf("Test directory created\n");
664 ```
665
666 ### mz_os_open_dir
667
668 Opens a directory for listing.
669
670 **Arguments**
671 |Type|Name|Description|
672 |-|-|-|
673 |const char *|path|Directory path|
674
675 **Return**
676 |Type|Description|
677 |-|-|
678 |DIR *|Directory enumeration handle, returns NULL if error.|
679
680 **Example**
681 ```
682 const char *search_dir = "c:\\test1\\";
683 DIR *dir = mz_open_dir(search_dir);
684 if (dir) {
685 printf("Dir %s was opened\n", search_dir);
686 mz_os_close_dir(dir);
687 }
688 ```
689
690 ### mz_os_read_dir
691
692 Reads a directory listing entry.
693
694 **Arguments**
695 |Type|Name|Description|
696 |-|-|-|
697 |DIR *|dir|Directory enumeration handle|
698
699 **Return**
700 |Type|Description|
701 |-|-|
702 |struct dirent *|Pointer to directory entry information structure. To get the name of the directory use the _d_name_ structure field.|
703
704 **Example**
705 ```
706 const char *search_dir = "c:\\test2\\";
707 DIR *dir = mz_open_dir(search_dir);
708 if (dir) {
709 struct dirent *entry = NULL;
710 printf("Dir %s was opened\n", search_dir);
711 while ((entry = mz_os_read_dir(dir))) {
712 printf("Dir entry: %s was opened\n", entry->d_name);
713 }
714 mz_os_close_dir(dir);
715 }
716 ```
717
718 ### mz_os_close_dir
719
720 Closes a directory that has been opened for listing.
721
722 **Arguments**
723 |Type|Name|Description|
724 |-|-|-|
725 |DIR *|dir|Directory enumeration handle|
726
727 **Return**
728 |Type|Description|
729 |-|-|
730 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
731
732 **Example**
733 ```
734 const char *search_dir = "c:\\test3\\";
735 DIR *dir = mz_open_dir(search_dir);
736 if (dir) {
737 struct dirent *entry = NULL;
738 printf("Dir %s was opened\n", search_dir);
739 while ((entry = mz_os_read_dir(dir))) {
740 printf("Dir entry: %s was opened\n", entry->d_name);
741 }
742 mz_os_close_dir(dir);
743 }
744 ```
745
746 ### mz_os_is_dir
747
748 Checks to see if path is a directory.
749
750 **Arguments**
751 |Type|Name|Description|
752 |-|-|-|
753 |const char *|path|File system path|
754
755 **Return**
756 |Type|Description|
757 |-|-|
758 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if it is a directory.|
759
760 **Example**
761 ```
762 const char *path = "c:\\test7.txt";
763 if (mz_os_is_dir(path) == MZ_OK)
764 printf("Path %s is a directory\n", path);
765 else
766 printf("Path %s is not a directory\n", path);
767 ```
768
769 ### mz_os_is_symlink
770
771 Checks to see if path is a symbolic link.
772
773 **Arguments**
774 |Type|Name|Description|
775 |-|-|-|
776 |const char *|path|File system path|
777
778 **Return**
779 |Type|Description|
780 |-|-|
781 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if it is a symbolic link.|
782
783 **Example**
784 ```
785 const char *path = "c:\\test7.txt";
786 if (mz_os_is_symlink(path) == MZ_OK)
787 printf("Path %s is a symbolic link\n", path);
788 else
789 printf("Path %s is not a symbolic link\n", path);
790 ```
791
792 ### mz_os_make_symlink
793
794 Creates a symbolic link pointing to a target.
795
796 **Arguments**
797 |Type|Name|Description|
798 |-|-|-|
799 |const char *|path|Link path|
800 |const char *|target_path|Actual path|
801
802 **Return**
803 |Type|Description|
804 |-|-|
805 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
806
807 **Example**
808 ```
809 const char *path = "c:\\test7.txt";
810 const char *target_path = "c:\\test8.txt";
811 if (mz_os_make_symlink(path, target_path) == MZ_OK)
812 printf("Symbolic link created at %s pointing to %s\n", path, target_path);
813 ```
814
815 ### mz_os_read_symlink
816
817 Gets the target path for a symbolic link.
818
819 **Arguments**
820 |Type|Name|Description|
821 |-|-|-|
822 |const char *|path|Link path|
823 |char *|target_path|Actual path|
824 |int32_t|max_path|Maximum bytes to store actual path|
825
826 **Return**
827 |Type|Description|
828 |-|-|
829 |int32_t|[MZ_ERROR](mz_error.md) code, MZ_OK if successful|
830
831 **Example**
832 ```
833 const char *path = "c:\\test7.txt";
834 const char *target_path = "c:\\test8.txt";
835 if (mz_os_make_symlink(path, target_path) == MZ_OK) {
836 char actual_path[120];
837 printf("Symbolic link created at %s pointing to %s\n", path, target_path);
838 if (mz_os_read_symlink(path, actual_path, sizeof(actual_path)) == MZ_OK) {
839 if (strcmp(target_path, actual_path) == 0) {
840 printf("Confirmed symbolic link created\n");
841 }
842 }
843 }
844 ```
845
846 ### mz_os_ms_time
847
848 Gets the time in milliseconds.
849
850 **Return**
851 |Type|Description|
852 |-|-|
853 |uint64_t|Current time in milliseconds|
854
855 **Example**
856 ```
857 uint64_t current_time = mz_os_ms_time();
858 printf("Current time in %lldms\n", current_time);
859 ```