当前位置: 首页>>代码示例>>Java>>正文


Java ErrorCodes类代码示例

本文整理汇总了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);
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:19,代码来源:CertificateNode.java

示例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;
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:20,代码来源:CertificatePoliciesNode.java

示例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;
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:26,代码来源:DocumentNode.java

示例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;
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:21,代码来源:PrincipalsNode.java

示例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;
   }
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:17,代码来源:LinkNode.java

示例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);
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:17,代码来源:FuseIotFS.java

示例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;
}
 
开发者ID:smacke,项目名称:gdrivefs,代码行数:18,代码来源:GoogleDriveLinuxFs.java

示例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;
}
 
开发者ID:smacke,项目名称:gdrivefs,代码行数:25,代码来源:GoogleDriveLinuxFs.java

示例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;
}
 
开发者ID:lisgie,项目名称:ChallengeTask_Group2,代码行数:22,代码来源:XattrExampleFS.java

示例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;
}
 
开发者ID:lisgie,项目名称:ChallengeTask_Group2,代码行数:20,代码来源:MemoryFS.java

示例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;
}
 
开发者ID:tbutter,项目名称:gyingpan,代码行数:18,代码来源:FuseFS.java

示例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();
	}
}
 
开发者ID:tbutter,项目名称:gyingpan,代码行数:24,代码来源:FuseFS.java

示例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;
}
 
开发者ID:tbutter,项目名称:gyingpan,代码行数:24,代码来源:FuseFS.java

示例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();
	}
}
 
开发者ID:tbutter,项目名称:gyingpan,代码行数:25,代码来源:FuseFS.java

示例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();
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:14,代码来源:AwsIot.java


注:本文中的net.fusejna.ErrorCodes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。