summaryrefslogtreecommitdiff
path: root/src/fileops.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement p_renameCarlos Martín Nieto2011-11-071-24/+1
| | | | | | Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Merge pull request #456 from brodie/perm-fixesVicent Martí2011-10-281-10/+9
|\ | | | | Create objects, indexes, and directories with the right file permissions
| * fileops/repository: create (most) directories with 0777 permissionsBrodie Rao2011-10-141-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To further match how Git behaves, this change makes most of the directories libgit2 creates in a git repo have a file mode of 0777. Specifically: - Intermediate directories created with git_futils_mkpath2file() have 0777 permissions. This affects odb_loose, reflog, and refs. - The top level folder for bare repos is created with 0777 permissions. - The top level folder for non-bare repos is created with 0755 permissions. - /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are created with 0777 permissions. Additionally, the following changes have been made: - fileops functions that create intermediate directories have grown a new dirmode parameter. The only exception to this is filebuf's lock_file(), which unconditionally creates intermediate directories with 0777 permissions when GIT_FILEBUF_FORCE is set. - The test runner now sets the umask to 0 before running any tests. This ensurses all file mode checks are consistent across systems. - t09-tree.c now does a directory permissions check. I've avoided adding this check to other tests that might reuse existing directories from the prefabricated test repos. Because they're checked into the repo, they have 0755 permissions. - Other assorted directories created by tests have 0777 permissions.
| * fileops/posix: replace usage of "int mode" with "mode_t mode"Brodie Rao2011-10-141-5/+5
| | | | | | | | | | Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t.
* | global: Properly use `git__` memory wrappersVicent Marti2011-10-281-3/+3
|/ | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Implment p_access and use it in git_fileutils_existsCarlos Martín Nieto2011-09-231-1/+1
| | | | Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Tabify everythingVicent Marti2011-09-191-6/+6
| | | | | | There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
* Cleanup legal dataVicent Marti2011-09-191-0/+6
| | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* compat: Move `mkstemp` to the POSIX compat layerVicent Marti2011-08-301-11/+3
|
* Add git_futils_readbuffer_updatedCarlos Martín Nieto2011-07-231-8/+35
| | | | | | | | | | | | | | This extends the git_fuitls_readbuffer function to only read in if the file's modification date is later than the given one. Some code paths want to check a file's modification date in order to decide whether they should read it or not. If they do want to read it, another stat call is done by futils. This function combines these two operations so we avoid one stat call each time we read a new or updated file. The git_futils_readbuffer functions is now a wrapper around the new function. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* refs: Cleanup reference renamingVicent Marti2011-07-061-12/+18
| | | | | | | `git_futils_rmdir_r`: rename, clean up. `git_reference_rename`: cleanup. Do not use 3x4096 buffers on the stack or things will get ugly very fast. We can reuse the same buffer.
* Remove duplicated recursive directory removal related codenulltoken2011-07-061-5/+8
|
* Fix windows specific issuesnulltoken2011-07-061-0/+2
| | | | | - msvc compilation warnings - not released file handle that prevents file removal
* fileops: add git_futils_rmdir_recurs()schu2011-07-061-0/+25
| | | | | | | git_futils_rmdir_recurs() shall remove the given directory and all subdirectories. This happens only if the directories are empty. Signed-off-by: schu <schu-github@schulog.org>
* fileops: add convenience function is_dot_or_dotdot()schu2011-07-061-7/+2
| | | | Signed-off-by: schu <schu-github@schulog.org>
* fileutils: Finish dropping the old `prettify_path`Vicent Marti2011-07-051-147/+0
|
* fileops: Fix stat() on directories for W32Vicent Marti2011-07-051-21/+10
| | | | | | | | The `stat` methods were having issues when called with a trailing slash in Windows platforms. We now use GetFileAttributes() where possible, which doesn't have this restriction.
* fileops: Drop `git_fileops_prettify_path`Vicent Marti2011-07-051-28/+10
| | | | | | | | | | The old `git_fileops_prettify_path` has been replaced with `git_path_prettify`. This is a much simpler method that uses the OS's `realpath` call to obtain the full path for directories and resolve symlinks. The `realpath` syscall is the original POSIX call in Unix system and an emulated version under Windows using the Windows API.
* fileops: CleanupVicent Marti2011-07-051-338/+79
| | | | | | | | | | | | | | | | Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.
* cleanup: remove trailing spacesKirill A. Shutemov2011-07-011-2/+2
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* Hide ".git" directory on Windows upon creation of a non bare repositorynulltoken2011-06-291-0/+12
| | | | Directory which name starts with a dot are hidden on Linux platforms. This patch makes libgit2 behaves similarly on Windows.
* test: Properly show error messagesVicent Marti2011-06-281-4/+3
|
* gitfo_read: fix read-loopschu2011-06-201-4/+2
| | | | Signed-off-by: schu <schu-github@schulog.org>
* mingw: Fix compilationVicent Marti2011-06-181-1/+1
|
* fileops: Cast the GetProcAddress valueVicent Marti2011-06-171-3/+4
|
* fileops: Fix 'GetFinalPathNameByHandleA' in old platformsVicent Marti2011-06-171-1/+17
|
* Merge pull request #251 from nulltoken/fix/msvc-warningsVicent Martí2011-06-151-2/+3
|\ | | | | Fix compilation warnings in MSVC
| * Add mode_t definition in MSVC compat layernulltoken2011-06-151-1/+1
| |
| * Fix compilation warnings in MSVCnulltoken2011-06-121-2/+3
| |
* | blob: Fix git_blob_create_fromfile()nulltoken2011-06-151-1/+1
|/
* Use "__inline" instead of "inline" with MSVCSebastian Schuberth2011-06-101-1/+1
| | | | MSVC supports "inline" only in C++ code, not in C code.
* Prefer to use S_IFLNK instead of _S_IFLNK for consistencySebastian Schuberth2011-06-101-1/+1
|
* windows: Fix Symlink issuesVicent Marti2011-06-081-8/+131
| | | | | | | | Handle Symlinks if they can be handled in Win32. This is not even compiled. Needs review. The lstat implementation is modified from core Git. The readlink implementation is modified from PHP.
* Merge pull request #243 from jpfender/symlinks2Vicent Martí2011-06-071-0/+8
|\ | | | | Symlinks NEW
| * fileops: Allow differentiation between deep and shallow exists()Jakob Pfender2011-06-071-0/+6
| | | | | | | | | | | | | | | | | | | | When calling gitfo_exists() on a symbolic link, sometimes we need to simply check whether the link exists and sometimes we need to check whether the file pointed to by the symlink exists. Introduce a new function gitfo_shallow_exists that only checks if the link exists and revert gitfo_exists to the original functionality of checking whether the file pointed to by the link exists.
| * index/fileops: Correctly process symbolic linksJakob Pfender2011-06-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | gitfo_exists() used to error out if the given file was a symbolic link, due to access() returning an error code. This is not expected behaviour, as gitfo_exists() should only check whether the file itself exists, not its link target if it is a symbolic link. Fix this by calling gitfo_lstat() instead, which is just a wrapper for lstat(). Also fix the same error in index_init_entry().
* | Merge pull request #242 from schu/fix-unused-2Vicent Martí2011-06-071-7/+12
|\ \ | |/ |/| fileops.c: fix unused warning v2
| * fileops.c: fix unused warningschu2011-06-061-7/+12
| | | | | | | | Signed-off-by: schu <schu-github@schulog.org>
* | Fileops: Fixed gitfo_mkdir_recurs so that it proprely works with a path ↵Romain Geissler2011-06-051-2/+5
|/ | | | | | without trailing slash. It used to discard the last directory if the path didn't have a trailing slash.
* Repository: Added some util functions that we'll need to discover repository ↵Romain Geissler2011-06-041-3/+3
| | | | | | | | path. retrieve_device returns the file device for a given path (so that we can detect device change while walking through parent directories). abspath returns a canonicalized path, symbolic link free. retrieive_ceiling_directories_offset returns the biggest path offset that path match in the ceiling directory list (so that we can stop at ceiling directories).
* Filebuf: Fixed a TODO in filebuf (real lock in lock_file)Romain Geissler2011-06-031-0/+14
| | | | Added gitfo_creat_locked and gitfo_creat_locked_force
* Fileops: Added gitfo_isfile.Romain Geissler2011-06-031-1/+20
| | | | | | Conflicts: src/fileops.c
* Fileops: Added a fourth argument to the path prettifying functions to use an ↵unknown2011-06-031-8/+18
| | | | | | alternate basepath. Fixed a Windows TO-DO in the prettifying functions.
* Fileops:retrieve_path_root_offset is now named ↵Romain Geissler2011-06-031-15/+15
| | | | gitfo_retrieve_path_root_offset (like other public functions). Added platform specific directory separator definition.
* gitfo_isdir: fix error messageschu2011-05-291-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* fileops: CleanupVicent Marti2011-05-231-93/+2
|
* fileops.c: Move to new error handling mechanismJakob Pfender2011-05-231-16/+18
|
* Move fileops.c to the new error handlingnulltoken2011-05-141-25/+36
|
* Improve the ODB writing backendVicent Marti2011-03-231-62/+2
| | | | | | | | | Temporary files when doing streaming writes are now stored inside the Objects folder, to prevent issues when moving files between disks/partitions. Add support for block writes to the ODB again (for those backends that cannot implement streaming).
* Fix compilation in MinGWVicent Marti2011-03-231-1/+1
|