Commit Graph

69 Commits

Author SHA1 Message Date
Jesse Stiller
3bd1918c5e Fixed typo "fot" and clarified slashpath.ext 2023-10-30 11:57:44 +10: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
gingerBill
986cba584e Add runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD where appropriate 2023-02-10 16:23:33 +00:00
gingerBill
f9f4551e8d Add user_data: rawptr to filepath.Walk_Proc callback 2022-12-05 22:31:35 +00:00
Daniel Gavin
25869b7504 Change open to be read only when opening directory 2022-07-25 11:34:03 +02:00
Tetralux
3a8adc6721 [path/slashpath] Change join() to take a slice instead of varargs
Achieves parity with filepath.join(), which was similarly changed a while back.
2022-07-21 17:49:31 +00:00
Tetralux
06884da42b [path/filepath] Change join() to take a []string instead of varargs
This makes passing an allocator easier, as you no longer have to resort to
named arguments:
Before:
  `join(a, b, c)` became `join(elems={a, b, c}, allocator=ally)`
After:
  `join({a, b, c})` becomes `join({a, b, c}, ally)`
2022-05-21 04:48:06 +00:00
gingerBill
dc832ad49f Minor fix 2022-05-12 13:20:55 +01: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
Sébastien Marie
5676c9e7eb initial OpenBSD support 2022-02-25 08:49:25 +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
f5697dd7f2 Merge branch 'master' into odin-global-constants-as-enums 2022-02-15 15:47:24 +00:00
CiD-
83e9a6b417 fix -vet for filepath/match.odin 2022-02-08 09:21:43 -05:00
Platin21
8b1100bf2b os.open does r/d as default which makes a call to open a dir invalid this should fix this problem 2022-02-05 23:12:55 +01: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
1d293749c2 Move core:path to core:path/slashpath
This is to reduce the confusion that occurs between that package and the `core:path/filepath` package
2022-01-17 11:38:15 +00:00
Dale Weiler
a55f0cfb63 fix memory leak in path.join 2021-11-22 10:25:54 -05:00
gingerBill
ceebd7b23c Correct context.allocator usage 2021-09-19 11:59:31 +01:00
gingerBill
ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill
4035fec784 Add more uses of or_return 2021-08-15 18:13:56 +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
André
22867ec6f0 fix variable name in path_unix
replace the immutable variable "path" (that is a parameter) with a new variable "path_str"
2021-04-20 22:09:10 +02:00
gingerBill
e3ee005404 Clean up path_unix.odin to make it not depend on package os 2021-04-11 19:05:01 +01:00
gingerBill
a2557142cc Update package os for package path/filepath support on macOS 2021-02-27 11:30:43 +00:00
gingerBill
aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
Luka Aleksić
92e23ec397 * Add some procedures to path_unix to mirror the path_windows API
* Add files stat_linux and dir_linux to mirror the stat/dir_windows API
* Add helper functions to os_linux that are used by the above
2021-01-21 20:20:38 +01:00
gingerBill
3bcccf88d5 vet all core packages 2021-01-09 23:43:34 +00:00
gingerBill
f6e2d74d10 Keep -vet happy 2020-12-14 14:36:45 +00:00
gingerBill
9408eb9580 Update odin doc to support multiple package outputs by passing multiple paths; Replace -all with -short
Example:
odin doc core/path core/path/filepath
2020-11-18 23:22:27 +00:00
gingerBill
11577db6a8 Minor fixes 2020-11-17 16:36:33 +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
41f6a684e1 Rename slice.sort_proc to slice.sort_by; add slice.sort_by_key 2020-10-16 14:55:36 +01:00
gingerBill
7fc3030c63 Update path/filepath to use new slice.sort; Add sort.reverse_interface 2020-10-14 20:47:13 +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
e95addb1f4 Revert user_data addition 2020-09-28 12:40:48 +01:00
gingerBill
d343e47a86 Add user_data parameter to filepath.walk and filepath.Walk_Proc 2020-09-28 12:39:34 +01:00