Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c91e32ab46bf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 79ff742663e4
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 6, 2017

  1. Update to jnr-posix 3.0.36.

    headius committed Mar 6, 2017
    Copy the full SHA
    6ef1d19 View commit details
  2. Copy the full SHA
    41f2bb6 View commit details
  3. Copy the full SHA
    79ff742 View commit details
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
jar 'com.github.jnr:jnr-enxio:0.16', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.17', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.35', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.36', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.8', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.4'
jar 'com.github.jnr:jffi:${jffi.version}'
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.35</version>
<version>3.0.36</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
44 changes: 41 additions & 3 deletions core/src/main/java/org/jruby/RubyFileStat.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
import java.nio.file.attribute.FileTime;
import java.util.concurrent.TimeUnit;

import jnr.posix.NanosecondFileStat;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import jnr.posix.FileStat;
@@ -62,6 +63,7 @@ public class RubyFileStat extends RubyObject {
private static final int S_IRUGO = (FileStat.S_IRUSR | FileStat.S_IRGRP | FileStat.S_IROTH);
private static final int S_IWUGO = (FileStat.S_IWUSR | FileStat.S_IWGRP | FileStat.S_IWOTH);
private static final int S_IXUGO = (FileStat.S_IXUSR | FileStat.S_IXGRP | FileStat.S_IXOTH);
public static final int BILLION = 1000000000;

private FileResource file;
private FileStat stat;
@@ -156,6 +158,9 @@ public IRubyObject initialize19(IRubyObject fname, Block unusedBlock) {
@JRubyMethod(name = "atime")
public IRubyObject atime() {
checkInitialized();
if (stat instanceof NanosecondFileStat) {
return RubyTime.newTimeFromNanoseconds(getRuntime(), stat.atime() * BILLION + ((NanosecondFileStat) stat).aTimeNanoSecs());
}
return getRuntime().newTime(stat.atime() * 1000);
}

@@ -211,6 +216,9 @@ public IRubyObject cmp(IRubyObject other) {
@JRubyMethod(name = "ctime")
public IRubyObject ctime() {
checkInitialized();
if (stat instanceof NanosecondFileStat) {
return RubyTime.newTimeFromNanoseconds(getRuntime(), stat.ctime() * BILLION + ((NanosecondFileStat) stat).cTimeNanoSecs());
}
return getRuntime().newTime(stat.ctime() * 1000);
}

@@ -357,19 +365,49 @@ public IRubyObject mode() {
@JRubyMethod(name = "mtime")
public IRubyObject mtime() {
checkInitialized();
if (stat instanceof NanosecondFileStat) {
return RubyTime.newTimeFromNanoseconds(getRuntime(), stat.mtime() * BILLION + ((NanosecondFileStat) stat).mTimeNanoSecs());
}
return getRuntime().newTime(stat.mtime() * 1000);
}

public IRubyObject mtimeEquals(IRubyObject other) {
return getRuntime().newBoolean(stat.mtime() == newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime());
FileStat otherStat = newFileStat(getRuntime(), other.convertToString().toString(), false).stat;
boolean equal = stat.mtime() == otherStat.mtime();

if (stat instanceof NanosecondFileStat && otherStat instanceof NanosecondFileStat) {
equal = equal && ((NanosecondFileStat) stat).mTimeNanoSecs() == ((NanosecondFileStat) otherStat).mTimeNanoSecs();
}

return getRuntime().newBoolean(equal);
}

public IRubyObject mtimeGreaterThan(IRubyObject other) {
return getRuntime().newBoolean(stat.mtime() > newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime());
FileStat otherStat = newFileStat(getRuntime(), other.convertToString().toString(), false).stat;
boolean gt;

if (stat instanceof NanosecondFileStat && otherStat instanceof NanosecondFileStat) {
gt = (stat.mtime() * BILLION + ((NanosecondFileStat) stat).mTimeNanoSecs())
> (otherStat.mtime() * BILLION + ((NanosecondFileStat) otherStat).mTimeNanoSecs());
} else {
gt = stat.mtime() > otherStat.mtime();
}

return getRuntime().newBoolean(gt);
}

public IRubyObject mtimeLessThan(IRubyObject other) {
return getRuntime().newBoolean(stat.mtime() < newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime());
FileStat otherStat = newFileStat(getRuntime(), other.convertToString().toString(), false).stat;
boolean lt;

if (stat instanceof NanosecondFileStat && otherStat instanceof NanosecondFileStat) {
lt = (stat.mtime() * BILLION + ((NanosecondFileStat) stat).mTimeNanoSecs())
< (otherStat.mtime() * BILLION + ((NanosecondFileStat) otherStat).mTimeNanoSecs());
} else {
lt = stat.mtime() < otherStat.mtime();
}

return getRuntime().newBoolean(lt);
}

@JRubyMethod(name = "nlink")
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/RubyTime.java
Original file line number Diff line number Diff line change
@@ -465,6 +465,12 @@ public static RubyTime newTime(Ruby runtime, long milliseconds) {
return newTime(runtime, new DateTime(milliseconds));
}

public static RubyTime newTimeFromNanoseconds(Ruby runtime, long nanoseconds) {
long milliseconds = nanoseconds / 1000000;
long extraNanoseconds = nanoseconds % 1000000;
return RubyTime.newTime(runtime, new DateTime(milliseconds), extraNanoseconds);
}

public static RubyTime newTime(Ruby runtime, DateTime dt) {
return new RubyTime(runtime, runtime.getTime(), dt);
}
1 change: 0 additions & 1 deletion spec/tags/ruby/core/file/split_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/ruby/core/file/stat/inspect_tags.txt

This file was deleted.