rugged 0.1.2 → 0.16.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -36
- data/Rakefile +20 -98
- data/ext/rugged/extconf.rb +44 -4
- data/ext/rugged/remote.c +215 -0
- data/ext/rugged/rugged.c +171 -0
- data/ext/rugged/rugged.h +126 -0
- data/ext/rugged/rugged_blob.c +99 -0
- data/ext/rugged/rugged_commit.c +224 -0
- data/ext/rugged/rugged_config.c +238 -0
- data/ext/rugged/rugged_index.c +440 -0
- data/ext/rugged/rugged_object.c +203 -0
- data/ext/rugged/rugged_reference.c +401 -0
- data/ext/rugged/rugged_repo.c +482 -0
- data/ext/rugged/rugged_revwalk.c +138 -0
- data/ext/rugged/rugged_signature.c +80 -0
- data/ext/rugged/rugged_tag.c +216 -0
- data/ext/rugged/rugged_tree.c +322 -0
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.c +1778 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.h +267 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/adler32.c +169 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.c +442 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.h +441 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.c +1834 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.h +342 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.c +340 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.h +11 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffixed.h +94 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.c +1480 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.h +122 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.c +330 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.h +62 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.c +1244 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zconf.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zlib.h +1613 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.h +274 -0
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +451 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +14 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +97 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +58 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +47 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +76 -0
- data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +43 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2.h +44 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +120 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +263 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +103 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +278 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +144 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +306 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +76 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/inttypes.h +305 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +51 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +173 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +331 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +100 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +218 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +309 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +176 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +290 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +65 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +63 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/stdint.h +247 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +279 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +318 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +59 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.c +135 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/bswap.h +97 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.c +113 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.h +32 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.c +111 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +67 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.c +299 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/common.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.c +418 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/config_file.c +1210 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +33 -0
- data/ext/rugged/vendor/libgit2-dist/src/dir.h +47 -0
- data/ext/rugged/vendor/libgit2-dist/src/errors.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +172 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +400 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +72 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.c +358 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.c +134 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.c +74 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.h +29 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +243 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +80 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.c +918 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/indexer.c +401 -0
- data/ext/rugged/vendor/libgit2-dist/src/map.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +272 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/src/object.c +295 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.c +672 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +855 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +485 -0
- data/ext/rugged/vendor/libgit2-dist/src/oid.c +388 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.h +99 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.c +270 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.h +84 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.c +426 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.h +77 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.h +69 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +26 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +141 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +81 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.c +1693 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.h +58 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.c +95 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.c +339 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.c +849 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +569 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.c +280 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.h +21 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +177 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.c +335 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/status.c +696 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.c +446 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +55 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +108 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.h +110 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +502 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +756 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +235 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +201 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +31 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.c +758 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/tsort.c +365 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.c +381 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.h +137 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.c +180 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.h +27 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +131 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +38 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +53 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +404 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +65 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +88 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +17 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/buf/basic.c +29 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +187 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +1073 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/add.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/new.c +36 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/read.c +209 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +39 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/write.c +77 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/dirent.c +222 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/filebuf.c +106 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/oid.c +18 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +139 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/string.c +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/strtol.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +66 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/index/rename.c +60 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/chars.c +52 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/compare.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/convert.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/data.h +323 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/fromstr.c +30 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/hash.c +162 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/short.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/size.c +13 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/type2string.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/tree/frompath.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose.c +84 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose_data.h +522 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/pack_data.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/packed.c +78 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/sorting.c +71 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/getters.c +68 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/single.c +38 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +628 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +322 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +638 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +344 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +255 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t05-revwalk.c +140 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +219 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +192 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +357 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +221 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +1294 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +41 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +448 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +310 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +83 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +89 -0
- data/lib/rugged.rb +4 -3
- data/lib/rugged/index.rb +0 -8
- data/lib/rugged/objects.rb +45 -0
- data/lib/rugged/repository.rb +29 -0
- data/lib/rugged/tree.rb +16 -6
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged/walker.rb +5 -0
- data/test/blob_test.rb +18 -14
- data/test/commit_test.rb +28 -26
- data/test/coverage/HEAD.json +1 -0
- data/test/coverage/cover.rb +106 -0
- data/test/fixtures/testrepo.git/refs/heads/new_name +1 -0
- data/test/index_test.rb +101 -78
- data/test/lib_test.rb +4 -4
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +75 -0
- data/test/remote_test.rb +19 -0
- data/test/repo_pack_test.rb +4 -4
- data/test/repo_test.rb +44 -15
- data/test/tag_test.rb +7 -17
- data/test/test_helper.rb +24 -5
- data/test/tree_test.rb +30 -12
- data/test/walker_test.rb +40 -31
- metadata +273 -50
- data/lib/rugged/person.rb +0 -20
- data/lib/rugged/tree_entry.rb +0 -9
- data/test/fixtures/testrepo.git/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae +0 -0
- data/test/fixtures/testrepo.git/objects/2f/3321418db5b2a841375b8b70880a8ab5a4148f +0 -0
- data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +0 -3
- data/test/fixtures/testrepo.git/objects/3d/b1b5ceace59ff65279757003763046fd4cbbe6 +0 -0
- data/test/fixtures/testrepo.git/objects/4c/d1604907792e2c43e03dcec1216f99d63e68c4 +0 -3
- data/test/fixtures/testrepo.git/objects/e0/f46d77041c149296549b01ed4a18b02c4b7400 +0 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_fnmatch__w32_h__
|
8
|
+
#define INCLUDE_fnmatch__w32_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
#define FNM_NOMATCH 1 /* Match failed. */
|
13
|
+
#define FNM_NOSYS 2 /* Function not supported (unused). */
|
14
|
+
|
15
|
+
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
|
16
|
+
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
|
17
|
+
#define FNM_PERIOD 0x04 /* Period must be matched by period. */
|
18
|
+
#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
|
19
|
+
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
|
20
|
+
|
21
|
+
#define FNM_IGNORECASE FNM_CASEFOLD
|
22
|
+
#define FNM_FILE_NAME FNM_PATHNAME
|
23
|
+
|
24
|
+
extern int p_fnmatch(const char *pattern, const char *string, int flags);
|
25
|
+
|
26
|
+
#endif /* _FNMATCH_H */
|
27
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "map.h"
|
9
|
+
#include <errno.h>
|
10
|
+
|
11
|
+
|
12
|
+
static DWORD get_page_size(void)
|
13
|
+
{
|
14
|
+
static DWORD page_size;
|
15
|
+
SYSTEM_INFO sys;
|
16
|
+
|
17
|
+
if (!page_size) {
|
18
|
+
GetSystemInfo(&sys);
|
19
|
+
page_size = sys.dwAllocationGranularity;
|
20
|
+
}
|
21
|
+
|
22
|
+
return page_size;
|
23
|
+
}
|
24
|
+
|
25
|
+
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
|
26
|
+
{
|
27
|
+
HANDLE fh = (HANDLE)_get_osfhandle(fd);
|
28
|
+
DWORD page_size = get_page_size();
|
29
|
+
DWORD fmap_prot = 0;
|
30
|
+
DWORD view_prot = 0;
|
31
|
+
DWORD off_low = 0;
|
32
|
+
DWORD off_hi = 0;
|
33
|
+
git_off_t page_start;
|
34
|
+
git_off_t page_offset;
|
35
|
+
|
36
|
+
assert((out != NULL) && (len > 0));
|
37
|
+
|
38
|
+
if ((out == NULL) || (len == 0)) {
|
39
|
+
errno = EINVAL;
|
40
|
+
return git__throw(GIT_ERROR, "Failed to mmap. No map or zero length");
|
41
|
+
}
|
42
|
+
|
43
|
+
out->data = NULL;
|
44
|
+
out->len = 0;
|
45
|
+
out->fmh = NULL;
|
46
|
+
|
47
|
+
if (fh == INVALID_HANDLE_VALUE) {
|
48
|
+
errno = EBADF;
|
49
|
+
return git__throw(GIT_ERROR, "Failed to mmap. Invalid handle value");
|
50
|
+
}
|
51
|
+
|
52
|
+
if (prot & GIT_PROT_WRITE)
|
53
|
+
fmap_prot |= PAGE_READWRITE;
|
54
|
+
else if (prot & GIT_PROT_READ)
|
55
|
+
fmap_prot |= PAGE_READONLY;
|
56
|
+
else {
|
57
|
+
errno = EINVAL;
|
58
|
+
return git__throw(GIT_ERROR, "Failed to mmap. Invalid protection parameters");
|
59
|
+
}
|
60
|
+
|
61
|
+
if (prot & GIT_PROT_WRITE)
|
62
|
+
view_prot |= FILE_MAP_WRITE;
|
63
|
+
if (prot & GIT_PROT_READ)
|
64
|
+
view_prot |= FILE_MAP_READ;
|
65
|
+
|
66
|
+
if (flags & GIT_MAP_FIXED) {
|
67
|
+
errno = EINVAL;
|
68
|
+
return git__throw(GIT_ERROR, "Failed to mmap. FIXED not set");
|
69
|
+
}
|
70
|
+
|
71
|
+
page_start = (offset / page_size) * page_size;
|
72
|
+
page_offset = offset - page_start;
|
73
|
+
|
74
|
+
if (page_offset != 0) { /* offset must be multiple of page size */
|
75
|
+
errno = EINVAL;
|
76
|
+
return git__throw(GIT_ERROR, "Failed to mmap. Offset must be multiple of page size");
|
77
|
+
}
|
78
|
+
|
79
|
+
out->fmh = CreateFileMapping(fh, NULL, fmap_prot, 0, 0, NULL);
|
80
|
+
if (!out->fmh || out->fmh == INVALID_HANDLE_VALUE) {
|
81
|
+
/* errno = ? */
|
82
|
+
out->fmh = NULL;
|
83
|
+
return git__throw(GIT_ERROR, "Failed to mmap. Invalid handle value");
|
84
|
+
}
|
85
|
+
|
86
|
+
assert(sizeof(git_off_t) == 8);
|
87
|
+
off_low = (DWORD)(page_start);
|
88
|
+
off_hi = (DWORD)(page_start >> 32);
|
89
|
+
out->data = MapViewOfFile(out->fmh, view_prot, off_hi, off_low, len);
|
90
|
+
if (!out->data) {
|
91
|
+
/* errno = ? */
|
92
|
+
CloseHandle(out->fmh);
|
93
|
+
out->fmh = NULL;
|
94
|
+
return git__throw(GIT_ERROR, "Failed to mmap. No data written");
|
95
|
+
}
|
96
|
+
out->len = len;
|
97
|
+
|
98
|
+
return GIT_SUCCESS;
|
99
|
+
}
|
100
|
+
|
101
|
+
int p_munmap(git_map *map)
|
102
|
+
{
|
103
|
+
assert(map != NULL);
|
104
|
+
|
105
|
+
if (!map)
|
106
|
+
return git__throw(GIT_ERROR, "Failed to munmap. Map does not exist");
|
107
|
+
|
108
|
+
if (map->data) {
|
109
|
+
if (!UnmapViewOfFile(map->data)) {
|
110
|
+
/* errno = ? */
|
111
|
+
CloseHandle(map->fmh);
|
112
|
+
map->data = NULL;
|
113
|
+
map->fmh = NULL;
|
114
|
+
return git__throw(GIT_ERROR, "Failed to munmap. Could not unmap view of file");
|
115
|
+
}
|
116
|
+
map->data = NULL;
|
117
|
+
}
|
118
|
+
|
119
|
+
if (map->fmh) {
|
120
|
+
if (!CloseHandle(map->fmh)) {
|
121
|
+
/* errno = ? */
|
122
|
+
map->fmh = NULL;
|
123
|
+
return git__throw(GIT_ERROR, "Failed to munmap. Could not close handle");
|
124
|
+
}
|
125
|
+
map->fmh = NULL;
|
126
|
+
}
|
127
|
+
|
128
|
+
return GIT_SUCCESS;
|
129
|
+
}
|
130
|
+
|
131
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_mingw_compat__
|
8
|
+
#define INCLUDE_mingw_compat__
|
9
|
+
|
10
|
+
#if defined(__MINGW32__)
|
11
|
+
|
12
|
+
/* use a 64-bit file offset type */
|
13
|
+
# define lseek _lseeki64
|
14
|
+
# define stat _stati64
|
15
|
+
# define fstat _fstati64
|
16
|
+
|
17
|
+
/* stat: file mode type testing macros */
|
18
|
+
# define _S_IFLNK 0120000
|
19
|
+
# define S_IFLNK _S_IFLNK
|
20
|
+
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
|
21
|
+
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#endif /* INCLUDE_mingw_compat__ */
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_msvc_compat__
|
8
|
+
#define INCLUDE_msvc_compat__
|
9
|
+
|
10
|
+
#if defined(_MSC_VER)
|
11
|
+
|
12
|
+
/* access() mode parameter #defines */
|
13
|
+
# define F_OK 0 /* existence check */
|
14
|
+
# define W_OK 2 /* write mode check */
|
15
|
+
# define R_OK 4 /* read mode check */
|
16
|
+
|
17
|
+
# define lseek _lseeki64
|
18
|
+
# define stat _stat64
|
19
|
+
# define fstat _fstat64
|
20
|
+
|
21
|
+
/* stat: file mode type testing macros */
|
22
|
+
# define _S_IFLNK 0120000
|
23
|
+
# define S_IFLNK _S_IFLNK
|
24
|
+
|
25
|
+
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
26
|
+
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
27
|
+
# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
|
28
|
+
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
|
29
|
+
|
30
|
+
# define mode_t unsigned short
|
31
|
+
|
32
|
+
/* case-insensitive string comparison */
|
33
|
+
# define strcasecmp _stricmp
|
34
|
+
# define strncasecmp _strnicmp
|
35
|
+
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#endif /* INCLUDE_msvc_compat__ */
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_posix__w32_h__
|
8
|
+
#define INCLUDE_posix__w32_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "fnmatch.h"
|
12
|
+
#include "utf-conv.h"
|
13
|
+
|
14
|
+
GIT_INLINE(int) p_link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new))
|
15
|
+
{
|
16
|
+
GIT_UNUSED_ARG(old)
|
17
|
+
GIT_UNUSED_ARG(new)
|
18
|
+
errno = ENOSYS;
|
19
|
+
return -1;
|
20
|
+
}
|
21
|
+
|
22
|
+
GIT_INLINE(int) p_mkdir(const char *path, mode_t GIT_UNUSED(mode))
|
23
|
+
{
|
24
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
25
|
+
int ret = _wmkdir(buf);
|
26
|
+
|
27
|
+
GIT_UNUSED_ARG(mode)
|
28
|
+
|
29
|
+
git__free(buf);
|
30
|
+
return ret;
|
31
|
+
}
|
32
|
+
|
33
|
+
extern int p_unlink(const char *path);
|
34
|
+
extern int p_lstat(const char *file_name, struct stat *buf);
|
35
|
+
extern int p_readlink(const char *link, char *target, size_t target_len);
|
36
|
+
extern int p_hide_directory__w32(const char *path);
|
37
|
+
extern char *p_realpath(const char *orig_path, char *buffer);
|
38
|
+
extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
|
39
|
+
extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4);
|
40
|
+
extern int p_mkstemp(char *tmp_path);
|
41
|
+
extern int p_setenv(const char* name, const char* value, int overwrite);
|
42
|
+
extern int p_stat(const char* path, struct stat* buf);
|
43
|
+
extern int p_chdir(const char* path);
|
44
|
+
extern int p_chmod(const char* path, mode_t mode);
|
45
|
+
extern int p_rmdir(const char* path);
|
46
|
+
extern int p_access(const char* path, mode_t mode);
|
47
|
+
extern int p_fsync(int fd);
|
48
|
+
extern int p_open(const char *path, int flags);
|
49
|
+
extern int p_creat(const char *path, mode_t mode);
|
50
|
+
extern int p_getcwd(char *buffer_out, size_t size);
|
51
|
+
extern int p_rename(const char *from, const char *to);
|
52
|
+
|
53
|
+
#endif
|
@@ -0,0 +1,404 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#include "posix.h"
|
8
|
+
#include "path.h"
|
9
|
+
#include "utf-conv.h"
|
10
|
+
#include <errno.h>
|
11
|
+
#include <io.h>
|
12
|
+
#include <fcntl.h>
|
13
|
+
|
14
|
+
|
15
|
+
int p_unlink(const char *path)
|
16
|
+
{
|
17
|
+
int ret = 0;
|
18
|
+
wchar_t* buf;
|
19
|
+
|
20
|
+
buf = gitwin_to_utf16(path);
|
21
|
+
_wchmod(buf, 0666);
|
22
|
+
ret = _wunlink(buf);
|
23
|
+
git__free(buf);
|
24
|
+
|
25
|
+
return ret;
|
26
|
+
}
|
27
|
+
|
28
|
+
int p_fsync(int fd)
|
29
|
+
{
|
30
|
+
HANDLE fh = (HANDLE)_get_osfhandle(fd);
|
31
|
+
|
32
|
+
if (fh == INVALID_HANDLE_VALUE) {
|
33
|
+
errno = EBADF;
|
34
|
+
return -1;
|
35
|
+
}
|
36
|
+
|
37
|
+
if (!FlushFileBuffers(fh)) {
|
38
|
+
DWORD code = GetLastError();
|
39
|
+
|
40
|
+
if (code == ERROR_INVALID_HANDLE)
|
41
|
+
errno = EINVAL;
|
42
|
+
else
|
43
|
+
errno = EIO;
|
44
|
+
|
45
|
+
return -1;
|
46
|
+
}
|
47
|
+
|
48
|
+
return 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
GIT_INLINE(time_t) filetime_to_time_t(const FILETIME *ft)
|
52
|
+
{
|
53
|
+
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
|
54
|
+
winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
|
55
|
+
winTime /= 10000000; /* Nano to seconds resolution */
|
56
|
+
return (time_t)winTime;
|
57
|
+
}
|
58
|
+
|
59
|
+
static int do_lstat(const char *file_name, struct stat *buf)
|
60
|
+
{
|
61
|
+
WIN32_FILE_ATTRIBUTE_DATA fdata;
|
62
|
+
wchar_t* fbuf = gitwin_to_utf16(file_name);
|
63
|
+
|
64
|
+
if (GetFileAttributesExW(fbuf, GetFileExInfoStandard, &fdata)) {
|
65
|
+
int fMode = S_IREAD;
|
66
|
+
|
67
|
+
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
68
|
+
fMode |= S_IFDIR;
|
69
|
+
else
|
70
|
+
fMode |= S_IFREG;
|
71
|
+
|
72
|
+
if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
73
|
+
fMode |= S_IWRITE;
|
74
|
+
|
75
|
+
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
76
|
+
fMode |= S_IFLNK;
|
77
|
+
|
78
|
+
buf->st_ino = 0;
|
79
|
+
buf->st_gid = 0;
|
80
|
+
buf->st_uid = 0;
|
81
|
+
buf->st_nlink = 1;
|
82
|
+
buf->st_mode = (mode_t)fMode;
|
83
|
+
buf->st_size = fdata.nFileSizeLow; /* Can't use nFileSizeHigh, since it's not a stat64 */
|
84
|
+
buf->st_dev = buf->st_rdev = (_getdrive() - 1);
|
85
|
+
buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
|
86
|
+
buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
|
87
|
+
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
|
88
|
+
|
89
|
+
git__free(fbuf);
|
90
|
+
return GIT_SUCCESS;
|
91
|
+
}
|
92
|
+
|
93
|
+
git__free(fbuf);
|
94
|
+
|
95
|
+
switch (GetLastError()) {
|
96
|
+
case ERROR_ACCESS_DENIED:
|
97
|
+
case ERROR_SHARING_VIOLATION:
|
98
|
+
case ERROR_LOCK_VIOLATION:
|
99
|
+
case ERROR_SHARING_BUFFER_EXCEEDED:
|
100
|
+
return GIT_EOSERR;
|
101
|
+
|
102
|
+
case ERROR_BUFFER_OVERFLOW:
|
103
|
+
case ERROR_NOT_ENOUGH_MEMORY:
|
104
|
+
return GIT_ENOMEM;
|
105
|
+
|
106
|
+
default:
|
107
|
+
return GIT_EINVALIDPATH;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
int p_lstat(const char *file_name, struct stat *buf)
|
112
|
+
{
|
113
|
+
int namelen, error;
|
114
|
+
char alt_name[GIT_PATH_MAX];
|
115
|
+
|
116
|
+
if ((error = do_lstat(file_name, buf)) == GIT_SUCCESS)
|
117
|
+
return GIT_SUCCESS;
|
118
|
+
|
119
|
+
/* if file_name ended in a '/', Windows returned ENOENT;
|
120
|
+
* try again without trailing slashes
|
121
|
+
*/
|
122
|
+
if (error != GIT_EINVALIDPATH)
|
123
|
+
return git__throw(GIT_EOSERR, "Failed to lstat file");
|
124
|
+
|
125
|
+
namelen = strlen(file_name);
|
126
|
+
if (namelen && file_name[namelen-1] != '/')
|
127
|
+
return git__throw(GIT_EOSERR, "Failed to lstat file");
|
128
|
+
|
129
|
+
while (namelen && file_name[namelen-1] == '/')
|
130
|
+
--namelen;
|
131
|
+
|
132
|
+
if (!namelen || namelen >= GIT_PATH_MAX)
|
133
|
+
return git__throw(GIT_ENOMEM, "Failed to lstat file");
|
134
|
+
|
135
|
+
memcpy(alt_name, file_name, namelen);
|
136
|
+
alt_name[namelen] = 0;
|
137
|
+
return do_lstat(alt_name, buf);
|
138
|
+
}
|
139
|
+
|
140
|
+
int p_readlink(const char *link, char *target, size_t target_len)
|
141
|
+
{
|
142
|
+
typedef DWORD (WINAPI *fpath_func)(HANDLE, LPWSTR, DWORD, DWORD);
|
143
|
+
static fpath_func pGetFinalPath = NULL;
|
144
|
+
HANDLE hFile;
|
145
|
+
DWORD dwRet;
|
146
|
+
wchar_t* link_w;
|
147
|
+
wchar_t* target_w;
|
148
|
+
|
149
|
+
/*
|
150
|
+
* Try to load the pointer to pGetFinalPath dynamically, because
|
151
|
+
* it is not available in platforms older than Vista
|
152
|
+
*/
|
153
|
+
if (pGetFinalPath == NULL) {
|
154
|
+
HINSTANCE library = LoadLibrary("kernel32");
|
155
|
+
|
156
|
+
if (library != NULL)
|
157
|
+
pGetFinalPath = (fpath_func)GetProcAddress(library, "GetFinalPathNameByHandleW");
|
158
|
+
|
159
|
+
if (pGetFinalPath == NULL)
|
160
|
+
return git__throw(GIT_EOSERR,
|
161
|
+
"'GetFinalPathNameByHandleW' is not available in this platform");
|
162
|
+
}
|
163
|
+
|
164
|
+
link_w = gitwin_to_utf16(link);
|
165
|
+
|
166
|
+
hFile = CreateFileW(link_w, // file to open
|
167
|
+
GENERIC_READ, // open for reading
|
168
|
+
FILE_SHARE_READ, // share for reading
|
169
|
+
NULL, // default security
|
170
|
+
OPEN_EXISTING, // existing file only
|
171
|
+
FILE_FLAG_BACKUP_SEMANTICS, // normal file
|
172
|
+
NULL); // no attr. template
|
173
|
+
|
174
|
+
git__free(link_w);
|
175
|
+
|
176
|
+
if (hFile == INVALID_HANDLE_VALUE)
|
177
|
+
return GIT_EOSERR;
|
178
|
+
|
179
|
+
if (target_len <= 0) {
|
180
|
+
return GIT_EINVALIDARGS;
|
181
|
+
}
|
182
|
+
|
183
|
+
target_w = (wchar_t*)git__malloc(target_len * sizeof(wchar_t));
|
184
|
+
|
185
|
+
dwRet = pGetFinalPath(hFile, target_w, target_len, 0x0);
|
186
|
+
if (dwRet >= target_len) {
|
187
|
+
git__free(target_w);
|
188
|
+
CloseHandle(hFile);
|
189
|
+
return GIT_ENOMEM;
|
190
|
+
}
|
191
|
+
|
192
|
+
if (!WideCharToMultiByte(CP_UTF8, 0, target_w, -1, target, target_len * sizeof(char), NULL, NULL)) {
|
193
|
+
git__free(target_w);
|
194
|
+
return GIT_EOSERR;
|
195
|
+
}
|
196
|
+
|
197
|
+
git__free(target_w);
|
198
|
+
CloseHandle(hFile);
|
199
|
+
|
200
|
+
if (dwRet > 4) {
|
201
|
+
/* Skip first 4 characters if they are "\\?\" */
|
202
|
+
if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') {
|
203
|
+
char tmp[GIT_PATH_MAX];
|
204
|
+
unsigned int offset = 4;
|
205
|
+
dwRet -= 4;
|
206
|
+
|
207
|
+
/* \??\UNC\ */
|
208
|
+
if (dwRet > 7 && target[4] == 'U' && target[5] == 'N' && target[6] == 'C') {
|
209
|
+
offset += 2;
|
210
|
+
dwRet -= 2;
|
211
|
+
target[offset] = '\\';
|
212
|
+
}
|
213
|
+
|
214
|
+
memcpy(tmp, target + offset, dwRet);
|
215
|
+
memcpy(target, tmp, dwRet);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
target[dwRet] = '\0';
|
220
|
+
return dwRet;
|
221
|
+
}
|
222
|
+
|
223
|
+
int p_open(const char *path, int flags)
|
224
|
+
{
|
225
|
+
int fd;
|
226
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
227
|
+
fd = _wopen(buf, flags | _O_BINARY);
|
228
|
+
|
229
|
+
git__free(buf);
|
230
|
+
return fd;
|
231
|
+
}
|
232
|
+
|
233
|
+
int p_creat(const char *path, mode_t mode)
|
234
|
+
{
|
235
|
+
int fd;
|
236
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
237
|
+
fd = _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode);
|
238
|
+
|
239
|
+
git__free(buf);
|
240
|
+
return fd;
|
241
|
+
}
|
242
|
+
|
243
|
+
int p_getcwd(char *buffer_out, size_t size)
|
244
|
+
{
|
245
|
+
wchar_t* buf = (wchar_t*)git__malloc(sizeof(wchar_t) * (int)size);
|
246
|
+
_wgetcwd(buf, (int)size);
|
247
|
+
|
248
|
+
if (!WideCharToMultiByte(CP_UTF8, 0, buf, -1, buffer_out, size, NULL, NULL)) {
|
249
|
+
git__free(buf);
|
250
|
+
return GIT_EOSERR;
|
251
|
+
}
|
252
|
+
|
253
|
+
git__free(buf);
|
254
|
+
return GIT_SUCCESS;
|
255
|
+
}
|
256
|
+
|
257
|
+
int p_stat(const char* path, struct stat* buf)
|
258
|
+
{
|
259
|
+
return do_lstat(path, buf);
|
260
|
+
}
|
261
|
+
|
262
|
+
int p_chdir(const char* path)
|
263
|
+
{
|
264
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
265
|
+
int ret = _wchdir(buf);
|
266
|
+
|
267
|
+
git__free(buf);
|
268
|
+
return ret;
|
269
|
+
}
|
270
|
+
|
271
|
+
int p_chmod(const char* path, mode_t mode)
|
272
|
+
{
|
273
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
274
|
+
int ret = _wchmod(buf, mode);
|
275
|
+
|
276
|
+
git__free(buf);
|
277
|
+
return ret;
|
278
|
+
}
|
279
|
+
|
280
|
+
int p_rmdir(const char* path)
|
281
|
+
{
|
282
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
283
|
+
int ret = _wrmdir(buf);
|
284
|
+
|
285
|
+
git__free(buf);
|
286
|
+
return ret;
|
287
|
+
}
|
288
|
+
|
289
|
+
int p_hide_directory__w32(const char *path)
|
290
|
+
{
|
291
|
+
int error;
|
292
|
+
wchar_t* buf = gitwin_to_utf16(path);
|
293
|
+
|
294
|
+
error = SetFileAttributesW(buf, FILE_ATTRIBUTE_HIDDEN) != 0 ?
|
295
|
+
GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */
|
296
|
+
|
297
|
+
git__free(buf);
|
298
|
+
|
299
|
+
if (error < GIT_SUCCESS)
|
300
|
+
error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path);
|
301
|
+
|
302
|
+
return error;
|
303
|
+
}
|
304
|
+
|
305
|
+
char *p_realpath(const char *orig_path, char *buffer)
|
306
|
+
{
|
307
|
+
int ret, alloc = 0;
|
308
|
+
wchar_t* orig_path_w = gitwin_to_utf16(orig_path);
|
309
|
+
wchar_t* buffer_w = (wchar_t*)git__malloc(GIT_PATH_MAX * sizeof(wchar_t));
|
310
|
+
|
311
|
+
if (buffer == NULL) {
|
312
|
+
buffer = (char *)git__malloc(GIT_PATH_MAX);
|
313
|
+
alloc = 1;
|
314
|
+
}
|
315
|
+
|
316
|
+
ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL);
|
317
|
+
git__free(orig_path_w);
|
318
|
+
|
319
|
+
if (!ret || ret > GIT_PATH_MAX) {
|
320
|
+
git__free(buffer_w);
|
321
|
+
if (alloc) git__free(buffer);
|
322
|
+
|
323
|
+
return NULL;
|
324
|
+
}
|
325
|
+
|
326
|
+
if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) {
|
327
|
+
git__free(buffer_w);
|
328
|
+
if (alloc) git__free(buffer);
|
329
|
+
}
|
330
|
+
|
331
|
+
git__free(buffer_w);
|
332
|
+
git_path_mkposix(buffer);
|
333
|
+
return buffer;
|
334
|
+
}
|
335
|
+
|
336
|
+
int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
|
337
|
+
{
|
338
|
+
#ifdef _MSC_VER
|
339
|
+
int len = _vsnprintf(buffer, count, format, argptr);
|
340
|
+
return (len < 0) ? _vscprintf(format, argptr) : len;
|
341
|
+
#else /* MinGW */
|
342
|
+
return vsnprintf(buffer, count, format, argptr);
|
343
|
+
#endif
|
344
|
+
}
|
345
|
+
|
346
|
+
int p_snprintf(char *buffer, size_t count, const char *format, ...)
|
347
|
+
{
|
348
|
+
va_list va;
|
349
|
+
int r;
|
350
|
+
|
351
|
+
va_start(va, format);
|
352
|
+
r = p_vsnprintf(buffer, count, format, va);
|
353
|
+
va_end(va);
|
354
|
+
|
355
|
+
return r;
|
356
|
+
}
|
357
|
+
|
358
|
+
extern int p_creat(const char *path, mode_t mode);
|
359
|
+
|
360
|
+
int p_mkstemp(char *tmp_path)
|
361
|
+
{
|
362
|
+
#if defined(_MSC_VER)
|
363
|
+
if (_mktemp_s(tmp_path, GIT_PATH_MAX) != 0)
|
364
|
+
return GIT_EOSERR;
|
365
|
+
#else
|
366
|
+
if (_mktemp(tmp_path) == NULL)
|
367
|
+
return GIT_EOSERR;
|
368
|
+
#endif
|
369
|
+
|
370
|
+
return p_creat(tmp_path, 0744);
|
371
|
+
}
|
372
|
+
|
373
|
+
int p_setenv(const char* name, const char* value, int overwrite)
|
374
|
+
{
|
375
|
+
if (overwrite != 1)
|
376
|
+
return EINVAL;
|
377
|
+
|
378
|
+
return (SetEnvironmentVariableA(name, value) == 0 ? GIT_EOSERR : GIT_SUCCESS);
|
379
|
+
}
|
380
|
+
|
381
|
+
int p_access(const char* path, mode_t mode)
|
382
|
+
{
|
383
|
+
wchar_t *buf = gitwin_to_utf16(path);
|
384
|
+
int ret;
|
385
|
+
|
386
|
+
ret = _waccess(buf, mode);
|
387
|
+
git__free(buf);
|
388
|
+
|
389
|
+
return ret;
|
390
|
+
}
|
391
|
+
|
392
|
+
extern int p_rename(const char *from, const char *to)
|
393
|
+
{
|
394
|
+
wchar_t *wfrom = gitwin_to_utf16(from);
|
395
|
+
wchar_t *wto = gitwin_to_utf16(to);
|
396
|
+
int ret;
|
397
|
+
|
398
|
+
ret = MoveFileExW(wfrom, wto, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) ? GIT_SUCCESS : GIT_EOSERR;
|
399
|
+
|
400
|
+
git__free(wfrom);
|
401
|
+
git__free(wto);
|
402
|
+
|
403
|
+
return ret;
|
404
|
+
}
|