Skip to content

Commit

Permalink
SplFileInfo::openFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed Mar 31, 2019
1 parent a3e6168 commit ea20683
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Peachpie.Library/Spl/SplFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,19 @@ public virtual string getExtension()
public virtual bool isLink() { throw new NotImplementedException(); }
public virtual bool isReadable() { throw new NotImplementedException(); }
public virtual bool isWritable() { throw new NotImplementedException(); }
public virtual SplFileObject openFile(string open_mode = "r", bool use_include_path = false, PhpResource context = null) { throw new NotImplementedException(); /* NOTE: use _file_class */ }
public virtual void setFileClass(string class_name = "SplFileObject") => _file_class = class_name;
public virtual void setInfoClass(string class_name = "SplFileInfo") => _info_class = class_name;
public virtual SplFileObject openFile(Context ctx, string open_mode = "r", bool use_include_path = false, PhpResource context = null)
{
if (string.IsNullOrEmpty(_file_class) || string.Equals(_file_class, nameof(SplFileObject), StringComparison.OrdinalIgnoreCase))
{
return new SplFileObject(ctx, _fullpath, open_mode, use_include_path, context);
}
else
{
return (SplFileObject)ctx.Create(_file_class, _fullpath, open_mode, use_include_path, PhpValue.FromClass(context));
}
}
public virtual void setFileClass(string class_name = nameof(SplFileObject)) => _file_class = class_name;
public virtual void setInfoClass(string class_name = nameof(SplFileInfo)) => _info_class = class_name;
public virtual string __toString() => _fullpath;
public override string ToString() => _fullpath;
}
Expand Down

0 comments on commit ea20683

Please # to comment.