Skip to content

Commit

Permalink
Implement new R15 efile driver API
Browse files Browse the repository at this point in the history
  • Loading branch information
krestenkrab committed Mar 22, 2013
1 parent 5c40a18 commit b62dbb5
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/main/java/erjang/driver/efile/EFile.java
Expand Up @@ -358,6 +358,7 @@ public static class Info {
public static final byte FILE_RESP_EOF = 8;
public static final byte FILE_RESP_FNAME = 9;
public static final byte FILE_RESP_ALL_DATA = 10;
public static final byte FILE_RESP_LFNAME = 11;
private static final byte[] FILE_RESP_ALL_DATA_HEADER = new byte[]{ FILE_RESP_ALL_DATA };

/* Options */
Expand Down Expand Up @@ -1571,7 +1572,7 @@ public void ready() throws Pausable {
return;
}

final int RESULT_SIZE = (1 + (29 * 4));
final int RESULT_SIZE = (1 + (17 * 4));

ByteBuffer res = ByteBuffer.allocate(RESULT_SIZE);
res.order(ByteOrder.BIG_ENDIAN);
Expand All @@ -1580,9 +1581,13 @@ public void ready() throws Pausable {
res.putLong(file_size);
res.putInt(file_type);

put_time(res, file_access_time);
put_time(res, file_modify_time);
put_time(res, file_create_time);
res.putLong(file_access_time);
res.putLong(file_modify_time);
res.putLong(file_create_time);

//put_time(res, file_access_time);
//put_time(res, file_modify_time);
//put_time(res, file_create_time);

res.putInt(file_mode);
res.putInt(1 /*file_links*/);
Expand Down Expand Up @@ -1929,7 +1934,19 @@ public String toString() {

void reply_list_directory(String[] files) throws Pausable {
for (int i = 0; i < files.length; i++) {
if (isUnicodeDriverInterface()) {
if (isLFNameDriverInterface()) {
// prim_file interface from R15 on
ByteBuffer reply = ByteBuffer.allocate(1);
reply.put(FILE_RESP_LFNAME);

ByteBuffer data = ByteBuffer.allocate(2+files[i].length());
data.limit(data.capacity());
data.position(0);
data.putShort((short)files[i].length());
IO.putstr(data, files[i], false);

driver_output2(reply, data);
} else if (isUnicodeDriverInterface()) {
// prim_file interface from R14 on
ByteBuffer reply = ByteBuffer.allocate(1);
reply.put(FILE_RESP_FNAME);
Expand Down Expand Up @@ -1972,4 +1989,8 @@ void reply_list_directory(String[] files) throws Pausable {
private static boolean isUnicodeDriverInterface() {
return ERT.runtime_info.unicodeDriverInterface;
}

private static boolean isLFNameDriverInterface() {
return ERT.runtime_info.unicodeDriverInterface;
}
}

0 comments on commit b62dbb5

Please sign in to comment.