pax_global_header 0000666 0000000 0000000 00000000064 12657454055 0014527 g ustar 00root root 0000000 0000000 52 comment=75eb99c42b00e70830dc53eb252dd03da48d0f67
jimfs-1.1/ 0000775 0000000 0000000 00000000000 12657454055 0012500 5 ustar 00root root 0000000 0000000 jimfs-1.1/.gitignore 0000664 0000000 0000000 00000000107 12657454055 0014466 0 ustar 00root root 0000000 0000000 .idea/
*.ims
*.iml
.classpath
.project
.settings/
target/
bin/
out/
jimfs-1.1/.travis.yml 0000664 0000000 0000000 00000001605 12657454055 0014613 0 ustar 00root root 0000000 0000000 sudo: false
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
install: mvn install -U -DskipTests=true
script: mvn verify -U -Dmaven.javadoc.skip=true
after_success:
- util/deploy_snapshot.sh
- util/update_snapshot_docs.sh
cache:
directories:
- $HOME/.m2
env:
global:
- secure: "YlCxYTG64KLbyyD2tvA7LwCrNMDCxBigClh8enVicY2Rw6EN9ZTE1YYZivsXAN42YtI1snpy4fTn1z42KUx6FhrlkXVnhLi9TO1lz1lVL4czhqj8MGew20+DJs7tlw3xWRJlRVhqGIXFfximqBsYskm7/+qnHga6uyyV59/VwEI="
- secure: "bTcwsovwxPXplZysfwgNkTR3hfHjb7UvWMlxeEkHHt3GQiZxIDKkiJbgW2mHAG/e/H0wfKQyujeCgQwxn1fa5ttR+UbGz+TIIY2tgjpIFkSbBRzlNGOO0Y23wQpFXXUv3lAY//cV1pa0HlCz+IWNq7ZqPZAoReDAkxExbbmydtE="
- secure: "JZnVEfpNSCLBZQg1MP7MuhzP9H8t2gGUU4salm5VsRKck27fgg1HwBxADolcVeON2k+2masSKLEQPkeYQizc/VN5hZsCZpTgYjuMke1ZLe1v0KsIdH3Rdt77fhhTqiT1BEkMV8tlBwiraYZz+41iLo+Ug5yjgfmXXayDjYm4h4w="
branches:
except:
- gh-pages
jimfs-1.1/CONTRIBUTING.md 0000664 0000000 0000000 00000001147 12657454055 0014734 0 ustar 00root root 0000000 0000000 Contributing to Jimfs
=====================
Contributions to Jimfs can be made by forking the repostitory and sending
a pull request. Before we can merge any pull requests from you, you must
first sign the Google [Contributor License Agreement][1].
When making changes to the code, please try to stay consistent with the
style of the existing code, specified by the [Google Java Style Guide][2].
Please also ensure that the code compiles and that changes have appropriate
tests.
[1]: https://developers.google.com/open-source/cla/individual
[2]: http://google-styleguide.googlecode.com/svn/trunk/javaguide.html
jimfs-1.1/LICENSE 0000664 0000000 0000000 00000026135 12657454055 0013514 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. jimfs-1.1/README.md 0000664 0000000 0000000 00000006157 12657454055 0013770 0 ustar 00root root 0000000 0000000 Jimfs
=====
Jimfs is an in-memory file system for Java 7 and above, implementing the
[java.nio.file](http://docs.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html)
abstract file system APIs.
[](https://travis-ci.org/google/jimfs)
[](https://maven-badges.herokuapp.com/maven-central/com.google.jimfs/jimfs)
Getting started
---------------
The latest release is [1.1](https://github.com/google/jimfs/releases/tag/v1.1).
It is available in Maven Central as
[com.google.jimfs:jimfs:1.1](http://search.maven.org/#artifactdetails%7Ccom.google.jimfs%7Cjimfs%7C1.1%7Cjar):
```xml
com.google.jimfsjimfs1.1
```
Basic use
---------
The simplest way to use Jimfs is to just get a new `FileSystem` instance from the `Jimfs` class and
start using it:
```java
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
...
// For a simple file system with Unix-style paths and behavior:
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path foo = fs.getPath("/foo");
Files.createDirectory(foo);
Path hello = foo.resolve("hello.txt"); // /foo/hello.txt
Files.write(hello, ImmutableList.of("hello world"), StandardCharsets.UTF_8);
```
What's supported?
-----------------
Jimfs supports almost all the APIs under `java.nio.file`. It supports:
- Creating, deleting, moving and copying files and directories.
- Reading and writing files with `FileChannel` or `SeekableByteChannel`, `InputStream`,
`OutputStream`, etc.
- Symbolic links.
- Hard links to regular files.
- `SecureDirectoryStream`, for operations relative to an _open_ directory.
- Glob and regex path filtering with `PathMatcher`.
- Watching for changes to a directory with a `WatchService`.
- File attributes. Built-in attribute views that can be supported include "basic", "owner",
"posix", "unix", "dos", "acl" and "user". Do note, however, that not all attribute views provide
_useful_ attributes. For example, while setting and reading POSIX file permissions is possible
with the "posix" view, those permissions will not actually affect the behavior of the file system.
Jimfs also supports creating file systems that, for example, use Windows-style paths and (to an
extent) behavior. In general, however, file system behavior is modeled after UNIX and may not
exactly match any particular real file system or platform.
License
-------
```
Copyright 2013 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
jimfs-1.1/jimfs/ 0000775 0000000 0000000 00000000000 12657454055 0013610 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/pom.xml 0000664 0000000 0000000 00000010063 12657454055 0015125 0 ustar 00root root 0000000 0000000
4.0.0com.google.jimfsjimfs-parent1.1jimfsbundleJimfs
Jimfs is an in-memory implementation of Java 7's java.nio.file abstract file system API.
com.google.guavaguavacom.ibm.icuicu4jtruecom.google.auto.serviceauto-servicetruecom.google.code.findbugsjsr305truejunitjunitcom.google.guavaguava-testlibcom.google.truthtruthmaven-source-pluginattach-sourcespost-integration-testjar-no-forkmaven-javadoc-pluginUTF-8UTF-8UTF-8com.google.jimfs.internal
http://docs.guava-libraries.googlecode.com/git-history/v${guava.version}/javadoc/
http://jsr-305.googlecode.com/svn/trunk/javadoc/
http://icu-project.org/apiref/icu4j/
http://docs.oracle.com/javase/7/docs/api/
attach-docspost-integration-testjarorg.apache.felixmaven-bundle-plugintruecom.google.common.jimfs.*
META-INF/services=target/classes/META-INF/services
jimfs-1.1/jimfs/src/ 0000775 0000000 0000000 00000000000 12657454055 0014377 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/ 0000775 0000000 0000000 00000000000 12657454055 0015323 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/ 0000775 0000000 0000000 00000000000 12657454055 0016244 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/com/ 0000775 0000000 0000000 00000000000 12657454055 0017022 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/com/google/ 0000775 0000000 0000000 00000000000 12657454055 0020276 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/com/google/common/ 0000775 0000000 0000000 00000000000 12657454055 0021566 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/com/google/common/jimfs/ 0000775 0000000 0000000 00000000000 12657454055 0022676 5 ustar 00root root 0000000 0000000 jimfs-1.1/jimfs/src/main/java/com/google/common/jimfs/AbstractAttributeView.java 0000664 0000000 0000000 00000002330 12657454055 0030021 0 ustar 00root root 0000000 0000000 /*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.nio.file.attribute.FileAttributeView;
/**
* Abstract base class for {@link FileAttributeView} implementations.
*
* @author Colin Decker
*/
abstract class AbstractAttributeView implements FileAttributeView {
private final FileLookup lookup;
protected AbstractAttributeView(FileLookup lookup) {
this.lookup = checkNotNull(lookup);
}
/**
* Looks up the file to get or set attributes on.
*/
protected final File lookupFile() throws IOException {
return lookup.lookup();
}
}
jimfs-1.1/jimfs/src/main/java/com/google/common/jimfs/AbstractWatchService.java 0000664 0000000 0000000 00000022016 12657454055 0027615 0 ustar 00root root 0000000 0000000 /*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.nio.file.ClosedWatchServiceException;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.Watchable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
/**
* Abstract implementation of {@link WatchService}. Provides the means for registering and managing
* keys but does not handle actually watching. Subclasses should implement the means of watching
* watchables, posting events to registered keys and queueing keys with the service by signalling
* them.
*
* @author Colin Decker
*/
abstract class AbstractWatchService implements WatchService {
private final BlockingQueue queue = new LinkedBlockingQueue<>();
private final WatchKey poison = new Key(this, null, ImmutableSet.>of());
private final AtomicBoolean open = new AtomicBoolean(true);
/**
* Registers the given watchable with this service, returning a new watch key for it. This
* implementation just checks that the service is open and creates a key; subclasses may override
* it to do other things as well.
*/
public Key register(Watchable watchable, Iterable extends WatchEvent.Kind>> eventTypes)
throws IOException {
checkOpen();
return new Key(this, watchable, eventTypes);
}
/**
* Returns whether or not this watch service is open.
*/
@VisibleForTesting
public boolean isOpen() {
return open.get();
}
/**
* Enqueues the given key if the watch service is open; does nothing otherwise.
*/
final void enqueue(Key key) {
if (isOpen()) {
queue.add(key);
}
}
/**
* Called when the given key is cancelled. Does nothing by default.
*/
public void cancelled(Key key) {}
@VisibleForTesting
ImmutableList queuedKeys() {
return ImmutableList.copyOf(queue);
}
@Nullable
@Override
public WatchKey poll() {
checkOpen();
return check(queue.poll());
}
@Nullable
@Override
public WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException {
checkOpen();
return check(queue.poll(timeout, unit));
}
@Override
public WatchKey take() throws InterruptedException {
checkOpen();
return check(queue.take());
}
/**
* Returns the given key, throwing an exception if it's the poison.
*/
@Nullable
private WatchKey check(@Nullable WatchKey key) {
if (key == poison) {
// ensure other blocking threads get the poison
queue.offer(poison);
throw new ClosedWatchServiceException();
}
return key;
}
/**
* Checks that the watch service is open, throwing {@link ClosedWatchServiceException} if not.
*/
protected final void checkOpen() {
if (!open.get()) {
throw new ClosedWatchServiceException();
}
}
@Override
public void close() {
if (open.compareAndSet(true, false)) {
queue.clear();
queue.offer(poison);
}
}
/**
* A basic implementation of {@link WatchEvent}.
*/
static final class Event implements WatchEvent {
private final Kind kind;
private final int count;
@Nullable private final T context;
public Event(Kind kind, int count, @Nullable T context) {
this.kind = checkNotNull(kind);
checkArgument(count >= 0, "count (%s) must be non-negative", count);
this.count = count;
this.context = context;
}
@Override
public Kind kind() {
return kind;
}
@Override
public int count() {
return count;
}
@Nullable
@Override
public T context() {
return context;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Event) {
Event> other = (Event>) obj;
return kind().equals(other.kind())
&& count() == other.count()
&& Objects.equals(context(), other.context());
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(kind(), count(), context());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("kind", kind())
.add("count", count())
.add("context", context())
.toString();
}
}
/**
* Implementation of {@link WatchKey} for an {@link AbstractWatchService}.
*/
static final class Key implements WatchKey {
@VisibleForTesting static final int MAX_QUEUE_SIZE = 256;
private static WatchEvent