本文整理汇总了Java中net.fusejna.ErrorCodes类的典型用法代码示例。如果您正苦于以下问题:Java ErrorCodes类的具体用法?Java ErrorCodes怎么用?Java ErrorCodes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorCodes类属于net.fusejna包,在下文中一共展示了ErrorCodes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rmdir
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int rmdir(String path) {
if (!children.isEmpty()) {
return -ErrorCodes.ENOTEMPTY();
}
int r = iotClient.updateCertificate(certificateId, false);
if (r != 0) {
return r;
}
r = iotClient.deleteCertificate(certificateId);
if (r != 0) {
return r;
}
return super.rmdir(path);
}
示例2: symunlink
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int symunlink(String name) {
Node node = getChild(name);
if (node == null) {
return -ErrorCodes.ENODEV();
}
Node sourceNode = this.find(name);
if (sourceNode instanceof PolicyNode) {
int r = iotClient.detachPolicy(certificateArn, sourceNode.getName());
if (r != 0) {
return r;
}
} else {
return -ErrorCodes.ENODEV();
}
return 0;
}
示例3: read
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public synchronized int read(String path, ByteBuffer buf, long bufSize, long offset, FileInfoWrapper info) {
try {
document = getDocument();
} catch (Exception e) {
return -ErrorCodes.EIO();
}
size = document.length();
if (offset < 0) {
offset = 0;
}
if (offset >= size) {
return 0;
}
if (bufSize < 0) {
bufSize = size;
}
if (offset + bufSize > size) {
bufSize = size - offset;
}
buf.put(document.getBytes(), (int) offset, (int) bufSize);
return (int) bufSize;
}
示例4: symunlink
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int symunlink(String name) {
Node node = getChild(name);
if (node == null) {
return -ErrorCodes.ENODEV();
}
Node sourceNode = this.find(name);
if (sourceNode instanceof CertificateNode) {
CertificateNode certificateNode = (CertificateNode) sourceNode;
int r = iotClient.detachCertificate(certificateNode.getCertificateArn(), thingName);
if (r != 0) {
return r;
}
} else {
return -ErrorCodes.ENODEV();
}
return 0;
}
示例5: readlink
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int readlink(ByteBuffer buffer, long size) {
String path;
if (this.parent == source.parent) {
path = source.name;
} else {
path = this.getRelativePathToRoot() + source.getAbsolutePath();
}
byte[] bytes = path.getBytes();
if (size < bytes.length) {
return -ErrorCodes.ENOSPC();
}
buffer.put(bytes);
return 0;
}
示例6: readdir
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int readdir(String path, DirectoryFiller filler) {
Node node = root.find(path);
if (node == null) {
return -ErrorCodes.ENOENT();
}
if (!node.isDir()) {
return -ErrorCodes.ENOTDIR();
}
if (!node.isInitDone()) {
node.init();
}
return node.readdir(filler);
}
示例7: truncate
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int truncate(final String path, final long offset)
{
// TODO: verify that the file at path is writable, in
// accordance w/ man pages. Perhaps this is always the case?
try {
getPath(path).truncate(offset);
FileWriteCollector collector = openFiles.get(path);
if (collector != null) {
collector.truncate(offset);
}
} catch (IOException e) {
e.printStackTrace();
return -ErrorCodes.EIO();
}
return 0;
}
示例8: release
import net.fusejna.ErrorCodes; //导入依赖的package包/类
/**
* According to fuse documentation, this is always
* preceded by a flush().
* Ref: http://fuse.sourceforge.net/doxygen/structfuse__operations.html
*/
@Override
public int release(String path, FileInfoWrapper info)
{
File f = fileHandles.remove(info.fh());
if (f == null) {
return ErrorCodes.EBADF(); // bad fd
}
try
{
f.close();
}
catch(IOException e)
{
e.printStackTrace();
return ErrorCodes.EIO();
}
openFiles.remove(f);
return 0;
}
示例9: setxattr
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int setxattr(final String path, final String xattr, final ByteBuffer buf, final long size, final int flags,
final int position)
{
if (!path.equals(filename)) {
return -ErrorCodes.ENOTSUP();
}
byte[] attr;
if (!helloTxtAttrs.containsKey(xattr)) {
attr = new byte[(int) (size + position)];
helloTxtAttrs.put(xattr, attr);
}
else {
attr = helloTxtAttrs.get(xattr);
if (attr.length < size + position) {
attr = Arrays.copyOf(attr, (int) (size + position));
}
}
buf.get(attr, position, (int) size);
return 0;
}
示例10: rename
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int rename(final String path, final String newName)
{
final MemoryPath p = getPath(path);
if (p == null) {
return -ErrorCodes.ENOENT();
}
final MemoryPath newParent = getParentPath(newName);
if (newParent == null) {
return -ErrorCodes.ENOENT();
}
if (!(newParent instanceof MemoryDirectory)) {
return -ErrorCodes.ENOTDIR();
}
p.delete();
p.rename(newName.substring(newName.lastIndexOf("/")));
((MemoryDirectory) newParent).add(p);
return 0;
}
示例11: getattr
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int getattr(String path, StatWrapper stat) {
Node n = gdrive.findPath(path, null);
if (n == null)
return -ErrorCodes.ENOENT();
stat.setAllTimesMillis(n.lastModified);
stat.size(n.getSize());
if (n.isDirectory())
stat.setMode(NodeType.DIRECTORY);
else {
if (n.isGoogleFile())
stat.setMode(NodeType.FILE, true, false, false);
else
stat.setMode(NodeType.FILE, true, true, false);
}
return 0;
}
示例12: read
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int read(String path, ByteBuffer buffer, long size, long offset,
FileInfoWrapper info) {
//System.out.println("read " + path + " " + offset + " " + size);
Node n = gdrive.findPath(path, info);
if (n.isDirectory())
return -ErrorCodes.EISDIR();
try {
synchronized (n) {
File f = n.cache();
RandomAccessFile aFile = new RandomAccessFile(f, "r");
FileChannel inChannel = aFile.getChannel();
buffer.limit((int) size);
int len = inChannel.read(buffer, offset);
aFile.close();
if(len < 0) len = 0;
return len;
}
} catch (IOException e) {
e.printStackTrace();
return -ErrorCodes.EAGAIN();
}
}
示例13: rename
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int rename(String path, String newName) {
System.out.println("rename " + path + " " + newName);
Node n = gdrive.findPath(path, null);
if (n == null)
return -ErrorCodes.ENOENT();
String fromDir = path.substring(0, path.lastIndexOf('/'));
String fromName = path.substring(path.lastIndexOf('/') + 1);
String toDir = newName.substring(0, newName.lastIndexOf('/'));
String toName = newName.substring(newName.lastIndexOf('/') + 1);
if (fromDir.equals(toDir)) {
n.rename(toName);
} else {
if (!fromName.equals(toName)) {
n.rename(toName);
}
Node toNode = gdrive.findPath(toDir, null);
if (toNode == null)
return -ErrorCodes.ENOENT();
n.move(gdrive.findPath(fromDir, null), toNode);
}
return 0;
}
示例14: write
import net.fusejna.ErrorCodes; //导入依赖的package包/类
@Override
public int write(String path, ByteBuffer buf, long bufSize,
long writeOffset, FileInfoWrapper info) {
Node n = gdrive.findPath(path, info);
if(n == null) return -ErrorCodes.ENOENT();
if (n.isDirectory())
return -ErrorCodes.EISDIR();
try {
synchronized (n) {
File f = n.cache();
RandomAccessFile aFile = new RandomAccessFile(f, "rw");
FileChannel inChannel = aFile.getChannel();
buf.limit((int)bufSize);
int len = inChannel.write(buf, writeOffset);
n.markDirty();
n.size = aFile.length();
aFile.close();
return len;
}
} catch (IOException e) {
e.printStackTrace();
return -ErrorCodes.EAGAIN();
}
}
示例15: translateException
import net.fusejna.ErrorCodes; //导入依赖的package包/类
private int translateException(Exception e) {
if (e instanceof ResourceNotFoundException) {
return -ErrorCodes.ENODEV();
} else if (e instanceof UnauthorizedException) {
return -ErrorCodes.EACCES();
} else if (e instanceof InvalidRequestException) {
return -ErrorCodes.EINVAL();
} else if (e instanceof DeleteConflictException) {
return -ErrorCodes.EBUSY();
}
return -ErrorCodes.EIO();
}