Commit Graph

27 Commits

Author SHA1 Message Date
gingerBill
4035a226da Fix filepath.rel allocation behaviour 2024-02-06 23:39:20 +00:00
gingerBill
14adcb9db8 Use or_break and or_continue where appropriate in the core library 2023-09-30 15:34:39 +01:00
gingerBill
49ab935ae9 Disallow for in in favour of for _ in 2023-08-08 14:56:12 +01:00
gingerBill
025fc2685d Add docs to core:path/filepath 2023-02-28 12:55:13 +00:00
Tetralux
b44b6e7e50 [path/filepath] Add file stem and long-extension procedures
Adds stem(), short_stem(), and long_ext(); also adds doc-comments to base() and ext().

The 'stem' is usually 'the name' of the file; the basename without the file extension.
To this end, this adds stem(), which is such that:

	stem(path) + ext(path) = base(path)

However, 'file extension' has two different meanings to what constitutes it!

 > What is the extension of: 'name.tar.gz' ?

Colloquially, you would likely think of it as 'a tarball' - which you might think is '.tar.gz'.
But, if you're writing code to process a file of this type, you would first treat it
as a Gzip file, and then treat the result as a TAR file - i.e: '.gz' ... _followed by_ '.tar'.

ext() returns '.gz' here, since that is the most-immediate format that you would need to use
to decode it; it would be a Gzip stream.

Sometimes though, you do actually want to consider these longer file extensions.

Perhaps you're extracting a tarball, and what to know what to call the intermediate tar file;
perhaps you want to check to see if this file is a tarball, or just a Gzip file;
or maybe you just want 'the name' of the file, and not this "strange 'name-and-part-of-the-extension' thing".

So, this also adds short_stem() and long_ext(), such that:

	short_stem(path) + long_ext(path) = base(path)

Thus, we can use either, but the most immediately-useful one is the easiest to reach for:

      stem('name.tar.gz') -> 'name.tar'
       ext('name.tar.gz') -> '.gz'

short_stem('name.tar.gz') -> 'name'
  long_ext('name.tar.gz') -> '.tar.gz'

These procedures are identical to their counterparts when the path only has a simple extension:

      stem('name.txt') -> 'name'
       ext('name.txt') -> '.txt'

short_stem('name.txt') -> 'name'
  long_ext('name.txt') -> '.txt'
2022-04-23 20:25:59 +00:00
Jeroen van Rijn
df32b5b46c [windows] Fix leak in glob. 2022-03-29 16:13:17 +02:00
gitlost
374e71e9b0 Fix issue #1537 "filepath.split_list requires a trailing separator"
Does `make()` with `count + 1` and appends final component (note a
  trailing separator will now result in an empty final component)
Adds test "tests/core/path/filepath/test_core_filepath.odin"
2022-03-23 17:44:35 +00:00
Patric Dexheimer
d7eabf571c Memory Leak
`dir` will leak memory if u use it with allocators that don´t care in freeing the memory at the end ( like arenas or the temp_allocator ) , because `strings.clone` and `strings.concatenate` are not using the passed allocator.
2022-02-20 02:10:34 -03:00
gingerBill
3d7d347192 Convert ODIN_OS and ODIN_ARCH to use enums rather than use strings 2022-01-20 19:56:05 +00:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill
86649e6b44 Core library clean up: Make range expressions more consistent and replace uses of .. with ..= 2021-06-14 11:15:25 +01:00
gingerBill
b9888f8f68 Fix linalg.transpose 2021-06-03 10:05:05 +01:00
gingerBill
32cda5d56a Or did it?! 2021-06-02 22:12:38 +01:00
gingerBill
a4d9847f45 FINALLY fix lazy_buffer_destroy 2021-06-02 22:12:20 +01:00
gingerBill
8aa6d70dec Fix filepath.lazy_buffer 2021-06-02 12:21:20 +01:00
gingerBill
ea6b222430 Clean up filepath.lazy_buffer memory leak 2021-06-02 12:19:25 +01:00
jockus
b110153b51 Fix accidental removal of newline 2021-05-27 12:04:24 +01:00
jockus
b261937233 Remove accidental core:fmt include in path/filepath 2021-05-27 12:03:37 +01:00
jockus
e8aa767c8d Fix deleting substring in filepath.release 2021-05-27 12:01:13 +01:00
gingerBill
a2557142cc Update package os for package path/filepath support on macOS 2021-02-27 11:30:43 +00:00
gingerBill
f6e2d74d10 Keep -vet happy 2020-12-14 14:36:45 +00:00
gingerBill
6ea000b648 Merge pull request #752 from powerc9000/patch-4
Fix a few bugs in path based code.
2020-10-24 01:28:15 +01:00
gingerBill
fa33476438 Improve default temp allocator; Fix filepath.abs behaviour on Windows 2020-10-13 14:40:13 +01:00
Clay Murray
062ae56f25 Fix a few bugs in path based code.
Trying to use path.dir and path.rel I found these two issues with the implementation.
2020-10-07 16:32:00 -06:00
gingerBill
0bd38ba1f6 Add some comments to explain what the differences between packages path and path/filepath 2020-09-26 20:17:54 +01:00
gingerBill
840af6825a Update packages os, path, and filepath 2020-09-26 16:02:03 +01:00
gingerBill
8cc5cd1494 Add package path/filepath; Add os.stat for windows (TODO: unix) 2020-09-25 20:20:53 +01:00