@Override public Void call(Void param) { warning(trace, Messages.ERR_INCLUDE_FAILED, "include_once", path); return null; } });
@Override public Void call(Void param) { warning(trace, Messages.ERR_INCLUDE_FAILED, "include", fileName); return null; } });
public static boolean touch(Environment env, TraceInfo trace, String path, long time, long atime) { File file = new File(path); if (!file.exists()) try { if (!file.createNewFile()) return false; } catch (IOException e) { env.warning(trace, e.getMessage()); return false; } return file.setLastModified(time * 1000); }
public static Memory ftell(Environment env, TraceInfo trace, Memory stream) { if (stream.instanceOf(Stream.CLASS_NAME)) { try { return env.invokeMethod(trace, stream, "getPosition"); } catch (Throwable throwable) { env.warning(trace, "ftell(): " + throwable.getMessage()); return Memory.FALSE; } } env.warning(trace, "ftell(): unable to get position from a non-stream"); return Memory.FALSE; }
public static Memory feof(Environment env, TraceInfo trace, Memory stream) { if (stream.instanceOf(Stream.CLASS_NAME)) { try { return env.invokeMethod(trace, stream, "eof"); } catch (Throwable throwable) { env.warning(trace, "feof(): " + throwable.getMessage()); return Memory.FALSE; } } env.warning(trace, "feof(): unable get eof from a non-stream"); return Memory.FALSE; }
protected static Invoker expectingCallback(Environment env, TraceInfo trace, int index, Memory memory) { Invoker invoker = Invoker.create(env, memory); if (invoker == null) { env.warning(trace, "expects parameter " + index + " to be valid callback"); return null; } if (invoker.canAccess(env) != 0) { env.warning(trace, "expects parameter " + index + " to be valid callback, cannot access"); return null; } return invoker; }
public static Memory fwrite(Environment env, TraceInfo trace, Memory stream, Memory value, Memory length) { if (stream.instanceOf(Stream.CLASS_NAME)) { try { return env.invokeMethod(trace, stream, "write", value, length); } catch (Throwable throwable) { env.warning(trace, "fwrite(): " + throwable.getMessage()); return Memory.FALSE; } } env.warning(trace, "fwrite(): unable to write to a non-stream"); return Memory.FALSE; }
public static Memory array_merge_recursive(Environment env, TraceInfo trace, Memory array, Memory... arrays) { try { return _array_merge(env, trace, true, array, arrays); } catch (RecursiveException e) { env.warning(trace, "recursion detected"); return Memory.NULL; } }
public static Memory filesize(Environment env, TraceInfo trace, String path) { try { return LongMemory.valueOf(new File(path).length()); } catch (Exception e) { env.warning(trace, "filesize(): file not found - %s", path); return Memory.FALSE; } }
public static Memory filectime(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class); return LongMemory.valueOf(attributes.creationTime().toMillis() / 1000); } catch (IOException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
public static Memory fileatime(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class); return LongMemory.valueOf(attributes.lastAccessTime().toMillis() / 1000); } catch (IOException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
public static Memory fileperms(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { int attribute = (int) Files.getAttribute(file, "unix:mode"); return LongMemory.valueOf(attribute); } catch (IOException | SecurityException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
public static Memory fileowner(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { int attribute = (int) Files.getAttribute(file, "unix:uid"); return LongMemory.valueOf(attribute); } catch (IOException | SecurityException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
public static Memory fopen(Environment env, TraceInfo trace, String path, String mode) { try { return ObjectMemory.valueOf(Stream.create(env, path, mode)); } catch (Throwable throwable) { env.warning(trace, "fopen(): failed to open stream, " + throwable.getMessage()); return Memory.FALSE; } }
public ForeachIterator __getIterator(TraceInfo trace, Memory memory, boolean getReferences, boolean getKeyReferences) { ForeachIterator iterator = memory.getNewIterator(this, getReferences, getKeyReferences); if (iterator == null) { warning(trace, "Invalid argument supplied for foreach()"); return invalidIterator; } iterator.setTrace(trace); return iterator; }
@Override public void check(String name, TraceInfo trace) { if (!method.isStatic()) env.warning(trace, name + "(): non-static method " + method.getSignatureString(false) +" should not be called statically"); }
public static void checkReturnReference(Memory memory, Environment env, TraceInfo trace) { if (memory.isImmutable() && !memory.isUndefined()) { env.warning(trace, Messages.ERR_RETURN_NOT_REFERENCE.fetch()); } }
public static Memory sprintf(Environment env, TraceInfo trace, String format, Memory... args) { PrintF printF = new PrintF(env.getLocale(), format, args); String result = printF.toString(); if (result == null) { env.warning(trace, "Too few arguments"); return Memory.NULL; } else return new StringMemory(result); }
protected static boolean expecting(Environment env, TraceInfo trace, int index, Memory memory, Memory.Type type) { if (memory.getRealType() != type) { env.warning(trace, "expects parameter " + index + " to be " + type.toString() + ", " + memory.getRealType().toString() + " given"); return false; } return true; }
@Immutable public static Memory strlen(Environment env, TraceInfo trace, Memory string) { if (string.isArray()) { env.warning(trace, "expects parameter 1 to be string, array given"); return Memory.NULL; } if (string instanceof BinaryMemory) return LongMemory.valueOf(string.getBinaryBytes(env.getDefaultCharset()).length); return LongMemory.valueOf(string.toString().length()); }