aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/util/file.h
Commit message (Collapse)AuthorAge
* Move path-manipulation functions to own library file.Gravatar ccalvarin2018-06-05
| | | | | | | | | | | Leave functions that make file accesses in the file library, and general blaze utilities in the blaze_util file, but move the functions that boil down to string manipulation and path formatting to their own file. (With the exception of getCWD, since absolute path syntax is relevant here.) Doing this largely to consolidate all Windows path control into a single place, so that it's easier to notice inconsistencies. For instance, ConvertPath currently makes Windows paths absolute, but not Posix paths, and MakeAbsolute relies on this behavior. In addition, JoinPath assumes Posix path syntax, which leads to some odd looking paths. These will be fixed in a followup change. (Found these issues while working on #4502, trying to fix the windows-specific system bazelrc.) RELNOTES: None. PiperOrigin-RevId: 199368226
* Don't set the +x bit by default on WriteFile().Gravatar lberki2017-06-27
| | | | | | | This change is a spiritual successor of https://bazel-review.googlesource.com/c/7410/ . That one had a merge conflict and it was small enough that a rewrite was easier than updating it. RELNOTES: None. PiperOrigin-RevId: 160251282
* Bazel client: do not use `errno`.Gravatar Laszlo Csomor2017-03-02
| | | | | | | | | | | | | | | Do not use `errno` in platform-independent code, because Windows API functions don't set it. This change abstracts away error handling and the functions whose `errno` result we care about, will set an input error variable. Fixes https://github.com/bazelbuild/bazel/issues/2506 -- PiperOrigin-RevId: 148977873 MOS_MIGRATED_REVID=148977873
* Bazel client: simplify {Read,Write}File semanticsGravatar Laszlo Csomor2017-03-01
| | | | | | | | | | | | | | | | Introduce a platform-specific file handle type (HANDLE on Windows, int on Linux/Darwin/FreeBSD) so we can get rid of the read_func and write_func functions, since they are always the same everywhere. Also include file_platform.h in file.h, since they are logically the same file (file_platform.h is just the platform-specific part of file.h). -- PiperOrigin-RevId: 148892736 MOS_MIGRATED_REVID=148892736
* Bazel client: add new ReadFile/WriteFile variantsGravatar Laszlo Csomor2017-02-27
| | | | | | | | | | | | | Instead of writing from / reading to a string, these variants take a buffer and a size. These methods will be used from ijar. See https://github.com/bazelbuild/bazel/issues/2157 -- PiperOrigin-RevId: 148635487 MOS_MIGRATED_REVID=148635487
* Rollback of commit 855fbe9ee447b7b37fd8c73dbc047d69b7ceffcf.Gravatar Yun Peng2017-02-01
| | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Causing bazel server restart every time on Windows See https://github.com/bazelbuild/bazel/issues/2466 *** Original change description *** Bazel client: platform-specific JoinPath This allows joining paths on "\" instead of "/" when building for Windows. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 146246700 MOS_MIGRATED_REVID=146246700
* Bazel client: platform-specific JoinPath Gravatar László Csomor2017-01-30
| | | | | | | | | | | | | This allows joining paths on "\" instead of "/" when building for Windows. See https://github.com/bazelbuild/bazel/issues/2107 -- Change-Id: I417ba40af6530650be2394db4bd445f0883d40e5 Reviewed-on: https://cr.bazel.build/8495 PiperOrigin-RevId: 145961689 MOS_MIGRATED_REVID=145961689
* Bazel client: move NormalizePath to Windows codeGravatar Laszlo Csomor2017-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | This method was only used by the Windows-specific code so move it there and adapt it to Windows paths. Update AsWindowsPath to normalize its output: this is necessary because AsWindowsPath's output is a widechar path string which we often prefix with the UNC prefix, but such paths must be normalized (the kernel won't do it if the path has an UNC prefix). Finally, add an AsWindowsPathWithUncPrefix method which does what the name suggests: converts the path to Windows path, makes it absolute, and adds the UNC prefix if necessary. (This is a very common operation when calling WinAPI functions and we'll use it a lot in subsequent changes.) See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 144060297 MOS_MIGRATED_REVID=144060297
* Bazel client; implement NormalizePathGravatar Laszlo Csomor2016-12-21
| | | | | | | | | | | | | | | | | | | | | | | | This method can normalize paths with "." and ".." and multiple "/" characters. E.g. normalize("../foo/./bar/../baz") = "foo/baz" This method enables us implementing PathExists on Windows. If the path to check is too long, we need to prefix it with "\\?\" for the Windows API functions to work, but then the path must be fully normalized and in Windows format. We already have functions to convert a path to Windows format but that doesn't normalize; with this function we can finally convert paths like "/c/foo/../bar" to L"\\?\c:\foo" and check if it exists. See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142648194 MOS_MIGRATED_REVID=142648194
* Bazel client, Windows: implement pipe handlingGravatar Laszlo Csomor2016-12-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create WindowsPipe which implements IPipe, and is a Windows-native implementation of pipe handling. It wraps the ::CreatePipe, ::WriteFile, and ::ReadFile API functions. Start using WindowsPipe on MSYS. Also move everything from file_test.cc into file_posix_test.cc, because these test methods heavily depend on POSIX and they test file_posix's functionality anyway. Also add tests for pipes: this will use the platform-specific implementation of IPipe. file_test.cc is now platform-independent, and we can test it with --cpu=x64_windows_msvc (and it passes!). See https://github.com/bazelbuild/bazel/issues/2107 Might also fix: https://github.com/bazelbuild/bazel/issues/2182 https://github.com/bazelbuild/bazel/issues/2248 -- PiperOrigin-RevId: 142240377 MOS_MIGRATED_REVID=142240377
* Bazel client: platform-specific {Read,Write}FileGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | Move blaze::ReadFile and blaze::WriteFile to file.h and file_platform.h (thus into the blaze_util namespace), and update references. This allows us to implement these methods in a platform-specific way. Also move UnlinkPath. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140328273
* Bazel client: fix compiler warningsGravatar Laszlo Csomor2016-11-22
| | | | | -- MOS_MIGRATED_REVID=139899429
* Bazel client: create a wrapper around Unix pipesGravatar Laszlo Csomor2016-11-18
| | | | | | | | | This allows implementing pipe-handling in a platform-specific way. Windows also supports pipes but through its own API. -- MOS_MIGRATED_REVID=139564316
* Bazel client: implement directory tree walkingGravatar Laszlo Csomor2016-11-16
| | | | | | | | | | | | | | | | | | | | | | This change: - merges the //src/{main,test}/cpp:file and //src/{main,test}/cpp:file_platform libraries because "file" and "file_platform" need each other and this makes logical sense anyway - implements a function in file_<platform> to run a custom function on every child of a directory - implements a function in file.cc to recursively traverse a directory tree, based on the previosly mentioned function - removes the corresponding logic from the Bazel client to make it more portable -- MOS_MIGRATED_REVID=139309562
* cpp: header hygienizationGravatar Thiago Farina2016-10-18
| | | | | | | | | | | * remove "using std::" declarations from header files * add missing "std::" to some string declarations at some header files * add "using std::string;" to some source files where necessary -- Change-Id: Ib64f62b5add499d6171fa922227194ac992fa542 Reviewed-on: https://bazel-review.googlesource.com/#/c/6630/ MOS_MIGRATED_REVID=136355671
* Move blaze_util::Which to standalone library.Gravatar Laszlo Csomor2016-09-29
| | | | | | | | | | | | | | | | | | This method is only used by blaze_util_linux.cc so instead of porting it to Windows, I'm moving it to a separate library. As part of this change I'm creating separate libraries for other sources in //src/main/cpp/util as well, so their dependencies are clearly defined in the BUILD file, plus we can port them one by one. This is part of the effort of compiling Bazel on Windows with the MSVC toolchain. -- MOS_MIGRATED_REVID=134636777
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Update include guards.Gravatar Han-Wen Nienhuys2015-05-15
| | | | | -- MOS_MIGRATED_REVID=93413161
* Update from Google.Gravatar Han-Wen Nienhuys2015-02-25
-- MOE_MIGRATED_REVID=85702957