about summary refs log tree commit diff
path: root/src/libstd/os.rs
AgeCommit message (Collapse)AuthorLines
2014-02-19Fix getting/setting huge env vars on windowsAlex Crichton-1/+13
On windows, the GetEnvironmentVariable function will return the necessary buffer size if the buffer provided was too small. This case previously fell through the checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice` method. This adds an extra case for when the return value is >= the buffer size, in which case we assume the return value as the new buffer size and try again. Closes #12376
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-3/+7
Many of the functions interacting with Windows APIs allocate a vector of 0's and do not retrieve a length directly from the API call, and so need to be sure to remove the unmodified junk at the end of the vector.
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-5/+10
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-2/+2
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-6/+2
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-14Use str::from_utf8_lossy() for os::env() and friendsKevin Ballard-11/+60
Parse the environment by default with from_utf8_lossy. Also provide byte-vector equivalents (e.g. os::env_as_bytes()). Unfortunately, setenv() can't have a byte-vector equivalent because of Windows support, unless we want to define a setenv_bytes() that fails under Windows for non-UTF8 (or non-UTF16).
2014-02-14Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()Kevin Ballard-4/+27
os::args() was using str::raw::from_c_str(), which would assert if the C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead, and add a separate function os::args_as_bytes() that returns the ~[u8] byte-vectors instead.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-07Removed prelude::* from libstd files.chromatic-4/+18
This replaces the imports from the prelude with the re-exported symbols.
2014-02-03Fixing remaining warnings and errors throughoutAlex Crichton-0/+1
2014-02-03std: Fixing all documentationAlex Crichton-3/+3
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Fix tests with io_error usageAlex Crichton-3/+1
2014-02-03std: Remove io::io_errorAlex Crichton-10/+6
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02std: rename fmt::Default to `Show`.Huon Wilson-1/+1
This is a better name with which to have a #[deriving] mode. Decision in: https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
2014-01-26Bring in the line-length policeAlex Crichton-51/+79
2014-01-24Fix zero-sized memory mappingCorey Richardson-2/+13
2014-01-24Use `mmap` to map in task stacks and guard pageCorey Richardson-22/+27
Also implement caching of stacks.
2014-01-24Add support for arbitrary flags to MemoryMap.Corey Richardson-7/+15
This also fixes up the documentation a bit, it was subtly incorrect.
2014-01-22Add std::os::self_exe_name()Ben Noordhuis-3/+21
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-32/+32
2014-01-21Remove unnecessary parentheses.Huon Wilson-5/+5
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-3/+1
2014-01-07Fix remaining cases of leaking importsAlex Crichton-3/+5
2013-12-24std: Stop reexporting the contents of 'mod consts'Alex Crichton-3/+1
This prevents usage of the win32 utf-16 helper functions from outside of libstd. Closes #9053
2013-12-24std: Move management of the exit code to std::osAlex Crichton-5/+15
Previously this functionality was located in std::rt::util, but there's no real reason for it to be located in there.
2013-12-19std::str: replace .as_imm_buf with .as_ptr.Huon Wilson-6/+4
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-49/+36
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-1/+1
There's no need for the restrictions of a closure with the above methods.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-2/+2
2013-12-15Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}.Huon Wilson-2/+2
2013-12-10librustpkg: Make `io::ignore_io_error()` use RAII; remove a few morePatrick Walton-1/+3
cells.
2013-12-08Remove dead codesKiet Tran-10/+2
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-17/+17
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-17/+17
2013-11-28Register new snapshotsAlex Crichton-1/+1
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-67/+61
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-1/+1
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-3/+3
2013-11-18Remove the C++ lock_and_signal typeAlex Crichton-7/+5
A the same time this purges all runtime support needed for statically initialized mutexes, moving all users over to the new Mutex type instead.
2013-11-11Move std::rt::io to std::ioAlex Crichton-3/+3
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-56/+4
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-10Register new snapshotsAlex Crichton-42/+6
2013-11-09std: os: Document MemoryMapCorey Richardson-3/+49
2013-11-04Move io::file to io::fs and fns out of FileAlex Crichton-19/+10
This renames the `file` module to `fs` because that more accurately describes its current purpose (manipulating the filesystem, not just files). Additionally, this adds an UnstableFileStat structure as a nested structure of FileStat to signify that the fields should not be depended on. The structure is currently flagged with #[unstable], but it's unlikely that it has much meaning. Closes #10241
2013-11-03Fill out the remaining functionality in io::fileAlex Crichton-2/+2
This adds bindings to the remaining functions provided by libuv, all of which are useful operations on files which need to get exposed somehow. Some highlights: * Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type * Moved all file-related methods to be static methods under `File` * All directory related methods are still top-level functions * Created `io::FilePermission` types (backed by u32) that are what you'd expect * Created `io::FileType` and refactored `FileStat` to use FileType and FilePermission * Removed the expanding matrix of `FileMode` operations. The mode of reading a file will not have the O_CREAT flag, but a write mode will always have the O_CREAT flag. Closes #10130 Closes #10131 Closes #10121
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-546/+3
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-10-24Test fixes and merge conflictsAlex Crichton-1/+3
2013-10-24Remove even more of std::ioAlex Crichton-59/+0
Big fish fried here: extra::json most of the compiler extra::io_util removed extra::fileinput removed Fish left to fry extra::ebml
2013-10-24Remove rt::io::supportAlex Crichton-2/+5
This removes the PathLike trait associated with this "support module". This is yet another "container of bytes" trait, so I didn't want to duplicate what already exists throughout libstd. In actuality, we're going to pass of C strings to the libuv APIs, so instead the arguments are now bound with the 'ToCStr' trait instead. Additionally, a layer of complexity was removed by immediately converting these type-generic parameters into CStrings to get handed off to libuv apis.
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-34/+34
Who doesn't like a massive renaming?