hudson.Util.chmod()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中hudson.Util.chmod()方法的一些代码示例,展示了Util.chmod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.chmod()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:chmod

Util.chmod介绍

[英]Run chmod natively if we can, otherwise fall back to Ant.
[中]如果可以的话,在本地运行chmod,否则就求助于Ant。

代码示例

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. public Void invoke(File f, VirtualChannel channel) throws IOException {
  2. Util.chmod(f, mask);
  3. return null;
  4. }
  5. });

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public static void chmod(File f, int mask) {
  2. chmod(f, mask, true);
  3. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public Void invoke(File f, VirtualChannel channel) throws IOException {
  2. Util.chmod(f, mask);
  3. return null;
  4. }
  5. });

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. public static void chmod(File f, int mask) {
  2. chmod(f, mask, true);
  3. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
  2. f.getParentFile().mkdirs();
  3. OutputStream os = new FileOutputStream(f);
  4. try {
  5. props.store(os, "Credential store");
  6. } finally {
  7. os.close();
  8. }
  9. // try to protect this file from other users, if we can.
  10. Util.chmod(f, 0600, false, null);
  11. return null;
  12. }
  13. });

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
  2. f.getParentFile().mkdirs();
  3. OutputStream os = new FileOutputStream(f);
  4. try {
  5. props.store(os,"Credential store");
  6. } finally {
  7. os.close();
  8. }
  9. // try to protect this file from other users, if we can.
  10. Util.chmod(f, 0600, false);
  11. return null;
  12. }
  13. });

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public static void chmod(File f, int mask, boolean tryNative) {
  2. chmod(f, mask, tryNative, NativeUtils.getInstance());
  3. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. private void process(File f) {
  2. if (f.isFile()) {
  3. if (Functions.isMustangOrAbove()) {
  4. f.setExecutable(true, false);
  5. } else {
  6. Util.chmod(f, 0755);
  7. }
  8. } else {
  9. File[] kids = f.listFiles();
  10. if (kids != null) {
  11. for (File kid : kids) {
  12. process(kid);
  13. }
  14. }
  15. }
  16. }
  17. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. private void process(File f) {
  2. if (f.isFile()) {
  3. if (Functions.isMustangOrAbove()) {
  4. f.setExecutable(true, false);
  5. } else {
  6. Util.chmod(f, 0755);
  7. }
  8. } else {
  9. File[] kids = f.listFiles();
  10. if (kids != null) {
  11. for (File kid : kids) {
  12. process(kid);
  13. }
  14. }
  15. }
  16. }
  17. }

代码示例来源:origin: org.eclipse.hudson/hudson-plugin-utils

  1. private void process(final File file) {
  2. assert file != null;
  3. if (file.isFile()) {
  4. if (Functions.isMustangOrAbove()) {
  5. if (!file.setExecutable(true, false)) {
  6. log.error("Failed to chmod: {}", file);
  7. }
  8. }
  9. else {
  10. Util.chmod(file.getAbsoluteFile(), mode);
  11. }
  12. }
  13. else {
  14. File[] children = file.listFiles();
  15. if (children != null) {
  16. for (File child : children) {
  17. process(child);
  18. }
  19. }
  20. }
  21. }
  22. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-plugin-utils

  1. private void process(final File file) {
  2. assert file != null;
  3. if (file.isFile()) {
  4. if (Functions.isMustangOrAbove()) {
  5. if (!file.setExecutable(true, false)) {
  6. log.error("Failed to chmod: {}", file);
  7. }
  8. }
  9. else {
  10. Util.chmod(file.getAbsoluteFile(), mode);
  11. }
  12. }
  13. else {
  14. File[] children = file.listFiles();
  15. if (children != null) {
  16. for (File child : children) {
  17. process(child);
  18. }
  19. }
  20. }
  21. }
  22. }

代码示例来源:origin: org.eclipse.hudson/hudson-test-framework

  1. /**
  2. * Extracts Ant and configures it.
  3. */
  4. protected Ant.AntInstallation configureDefaultAnt() throws Exception {
  5. Ant.AntInstallation antInstallation;
  6. if (System.getenv("ANT_HOME") != null) {
  7. antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
  8. } else {
  9. LOGGER.warning("Extracting a copy of Ant bundled in the test harness. "
  10. + "To avoid a performance hit, set the environment variable ANT_HOME to point to an Ant installation.");
  11. FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
  12. ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
  13. File antHome = createTmpDir();
  14. ant.unzip(new FilePath(antHome));
  15. // TODO: switch to tar that preserves file permissions more easily
  16. if (!Functions.isWindows()) {
  17. Util.chmod(new File(antHome, "apache-ant-1.8.1/bin/ant"), 0755);
  18. }
  19. antInstallation = new AntInstallation("default", new File(antHome, "apache-ant-1.8.1").getAbsolutePath(), NO_PROPERTIES);
  20. }
  21. hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
  22. return antInstallation;
  23. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. /**
  2. * Reads from a tar stream and stores obtained files to the base dir.
  3. */
  4. private static void readFromTar(String name, File baseDir, InputStream in) throws IOException {
  5. TarInputStream t = new TarInputStream(in);
  6. try {
  7. TarEntry te;
  8. while ((te = t.getNextEntry()) != null) {
  9. File f = new File(baseDir,te.getName());
  10. if(te.isDirectory()) {
  11. f.mkdirs();
  12. } else {
  13. File parent = f.getParentFile();
  14. if (parent != null) parent.mkdirs();
  15. IOUtils.copy(t,f);
  16. f.setLastModified(te.getModTime().getTime());
  17. int mode = te.getMode()&0777;
  18. if(mode!=0 && !Functions.isWindows()) // be defensive
  19. Util.chmod(f, mode);
  20. }
  21. }
  22. } catch(IOException e) {
  23. throw new IOException2("Failed to extract "+name,e);
  24. } finally {
  25. t.close();
  26. }
  27. }

代码示例来源:origin: org.eclipse.hudson/hudson-test-framework

  1. Util.chmod(new File(mvnHome, mavenVersion + "/bin/mvn"), 0755);

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. Util.chmod(f, mode, true, nativeUtils);

相关文章