本文整理了Java中hudson.FilePath.isUnix()
方法的一些代码示例,展示了FilePath.isUnix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.isUnix()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:isUnix
[英]Checks if the remote path is Unix.
[中]检查远程路径是否为Unix。
代码示例来源:origin: jenkinsci/jenkins
private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel) {
if(isAbsolute(rel)) return rel;
if(base.isUnix()) {
// shouldn't need this replace, but better safe than sorry
return base.remote+'/'+rel.replace('\\','/');
} else {
// need this replace, see Slave.getWorkspaceFor and AbstractItem.getFullName, nested jobs on Windows
// agents will always have a rel containing at least one '/' character. JENKINS-13649
return base.remote+'\\'+rel.replace('/','\\');
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the file permission bit mask.
*
* @return
* -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException, PosixException {
if(!isUnix()) return -1;
return act(new Mode());
}
private class Mode extends SecureFileCallable<Integer> {
代码示例来源:origin: jenkinsci/jenkins
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask
* File permission mask. To simplify the permission copying,
* if the parameter is -1, this method becomes no-op.
* <p>
* please note mask is expected to be an octal if you use <a href="http://en.wikipedia.org/wiki/Chmod">chmod command line values</a>,
* so preceded by a '0' in java notation, ie <code>chmod(0644)</code>
* <p>
* Only supports setting read, write, or execute permissions for the
* owner, group, or others, so the largest permissible value is 0777.
* Attempting to set larger values (i.e. the setgid, setuid, or sticky
* bits) will cause an IOException to be thrown.
*
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if(!isUnix() || mask==-1) return;
act(new Chmod(mask));
}
private class Chmod extends SecureFileCallable<Void> {
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel) {
if(isAbsolute(rel)) return rel;
if(base.isUnix()) {
// shouldn't need this replace, but better safe than sorry
return base.remote+'/'+rel.replace('\\','/');
} else {
// need this replace, see Slave.getWorkspaceFor and AbstractItem.getFullName, nested jobs on Windows
// agents will always have a rel containing at least one '/' character. JENKINS-13649
return base.remote+'\\'+rel.replace('/','\\');
}
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Gets the file permission bit mask.
*
* @return
* -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException {
if(!isUnix()) return -1;
return act(new FileCallable<Integer>() {
public Integer invoke(File f, VirtualChannel channel) throws IOException {
return PosixAPI.get().stat(f.getPath()).mode();
}
});
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Gets the file permission bit mask.
*
* @return
* -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException {
if(!isUnix()) return -1;
return act(new FileCallable<Integer>() {
public Integer invoke(File f, VirtualChannel channel) throws IOException {
return PosixAPI.get().stat(f.getPath()).mode();
}
});
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Gets the file permission bit mask.
*
* @return
* -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException, PosixException {
if(!isUnix()) return -1;
return act(new SecureFileCallable<Integer>() {
private static final long serialVersionUID = 1L;
public Integer invoke(File f, VirtualChannel channel) throws IOException {
return IOUtils.mode(stating(f));
}
});
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask
* File permission mask. To simplify the permission copying,
* if the parameter is -1, this method becomes no-op.
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if(!isUnix() || mask==-1) return;
act(new FileCallable<Void>() {
public Void invoke(File f, VirtualChannel channel) throws IOException {
_chmod(f, mask);
return null;
}
});
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask
* File permission mask. To simplify the permission copying,
* if the parameter is -1, this method becomes no-op.
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if(!isUnix() || mask==-1) return;
act(new FileCallable<Void>() {
public Void invoke(File f, VirtualChannel channel) throws IOException {
_chmod(f, mask);
return null;
}
});
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask
* File permission mask. To simplify the permission copying,
* if the parameter is -1, this method becomes no-op.
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if(!isUnix() || mask==-1) return;
act(new FileCallable<Void>() {
public Void invoke(File f, VirtualChannel channel) throws IOException {
Util.chmod(f, mask);
return null;
}
});
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask File permission mask. To simplify the permission copying, if
* the parameter is -1, this method becomes no-op.
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if (!isUnix() || mask == -1) {
return;
}
act(new FileCallable<Void>() {
public Void invoke(File f, VirtualChannel channel) throws IOException {
Util.chmod(f, mask);
return null;
}
});
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Gets the file permission bit mask.
*
* @return -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException {
if (!isUnix()) {
return -1;
}
return act(new FileCallable<Integer>() {
public Integer invoke(File f, VirtualChannel channel) throws IOException {
int mode = -1;
try {
mode = NativeUtils.getInstance().mode(f);
} catch (NativeAccessException ex) {
LOGGER.log(Level.WARNING, "Native function mod failed.");
}
return mode;
}
});
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Sets the file permission.
*
* On Windows, no-op.
*
* @param mask
* File permission mask. To simplify the permission copying,
* if the parameter is -1, this method becomes no-op.
* <p>
* please note mask is expected to be an octal if you use <a href="http://en.wikipedia.org/wiki/Chmod">chmod command line values</a>,
* so preceded by a '0' in java notation, ie <code>chmod(0644)</code>
*
* @since 1.303
* @see #mode()
*/
public void chmod(final int mask) throws IOException, InterruptedException {
if(!isUnix() || mask==-1) return;
act(new SecureFileCallable<Void>() {
private static final long serialVersionUID = 1L;
public Void invoke(File f, VirtualChannel channel) throws IOException {
// TODO first check for Java 7+ and use PosixFileAttributeView
_chmod(writing(f), mask);
return null;
}
});
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Gets the file permission bit mask.
*
* @return
* -1 on Windows, since such a concept doesn't make sense.
* @since 1.311
* @see #chmod(int)
*/
public int mode() throws IOException, InterruptedException {
if(!isUnix()) return -1;
return act(new FileCallable<Integer>() {
public Integer invoke(File f, VirtualChannel channel) throws IOException {
int mode = -1;
try {
mode = NativeUtils.getInstance().mode(f);
} catch (NativeAccessException ex) {
LOGGER.log(Level.WARNING, "Native function mod failed ({0})", NativeUtils.getInstance().getLastUnixError());
}
return mode;
}
});
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Construct a path starting with a base location.
* @param base starting point for resolution, and defines channel
* @param rel a path which if relative will be resolved against base
*/
public FilePath(FilePath base, String rel) {
this.channel = base.channel;
if(isAbsolute(rel)) {
// absolute
this.remote = normalize(rel);
} else
if(base.isUnix()) {
this.remote = normalize(base.remote+'/'+rel);
} else {
//Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
}
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Construct a path starting with a base location.
* @param base starting point for resolution, and defines channel
* @param rel a path which if relative will be resolved against base
*/
public FilePath(FilePath base, String rel) {
this.channel = base.channel;
if(isAbsolute(rel)) {
// absolute
this.remote = normalize(rel);
} else
if(base.isUnix()) {
this.remote = normalize(base.remote+'/'+rel);
} else {
//Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Construct a path starting with a base location.
*
* @param base starting point for resolution, and defines channel
* @param rel a path which if relative will be resolved against base
*/
public FilePath(FilePath base, String rel) {
this.channel = base.channel;
if (isAbsolute(rel)) {
// absolute
this.remote = normalize(rel);
} else if (base.isUnix()) {
this.remote = normalize(base.remote + '/' + rel);
} else {
//Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
this.remote = normalize(base.remote + '\\' + StringUtils.replace(rel, "/", "\\"));
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Construct a path starting with a base location.
* @param base starting point for resolution, and defines channel
* @param rel a path which if relative will be resolved against base
*/
public FilePath(FilePath base, String rel) {
this.channel = base.channel;
if(isAbsolute(rel)) {
// absolute
this.remote = normalize(rel);
} else
if(base.isUnix()) {
this.remote = normalize(base.remote+'/'+rel);
} else {
//Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
}
}
内容来源于网络,如有侵权,请联系作者删除!