Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6366593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:26:27+00:00 2026-05-25T00:26:27+00:00

On an unmodified install, how can I configure Quercus so that PHP file functions

  • 0

On an unmodified install, how can I configure Quercus so that PHP file functions use Apache Commons VFS to access files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:26:28+00:00Added an answer on May 25, 2026 at 12:26 am

    That’s quite a bit of development! More than can fit in an answer here. In outline, there are two main obstacles to overcome here:

    1. implementing functions in PHP that use VFS I/O rather than regular I/O
    2. replacing the standard file functions (fopen/fread/fwrite/fclose) with the functions above.

    Implementing a Quercus module is fairly straightforward – you define functions to be available in php. The main work of the module is to provide the interface to VFS.

    class VFSModule extends AbstractQuercusModule
    {
    
        FileSystemManager fsManager = VFS.getManager();
    
        public Object vfs_fopen(String filename, String mode) {            
            FileObject file =  fsManager.resolveFile(filename);
            if (mode.equals("r"))
                return file.getContent().getInputStream();
            else if (mode.equals("w"))
                return file.getContent().getOutputStream();
            throw new IllegalArgumentException("unsupported mode; "+mode);                
        }
    
        function String vfs_fread(Object stream, int length) {
            InputStream in = (InputStream)stream;
            byte[] buffer = new byte[length];
            int read = in.read(buffer);
            // todo - handle smaller than length reads
            return buffer;
        }
    
        function void vfs_fwrite(Object stream, int length, byte[] data) {
            OutputStream out = (OutputStream)stream;
            out.write(data);
        }
    
    } 
    

    (IOException handling is left out to avoid clutter.)

    Once the module is coded, as a sanity test, write some php script that calls the custom vfs functions from this module.

    Since you can call java (and vfs) directly from PHP, you could do this without a module by coding the equivalent VFS calls in PHP.

    $mgr = org.apache.commons.vfs2.VFS.getManager();
    
    function vfs_open($filename, $mode) {
       if ($mode=="r") {
          return $mgr->resolveFile($filename)->content->getInputStream();
       }
       else if ($mode=="w") {
          return $mgr->resolveFile($filename)->content->getOutputStream();
       }
      // todo - handle other mode combinations
    }
    function vfs_read($resource, $length) {
       $buf = str_repeat(" ", 1024);
       $lenRead = $resource->read($buf, 0, 1024);
       if ($lenRead<0) return "";
       return substr($buf, 0, $lenRead);
    }
    

    The next part is mapping these functions to the standard php file functions. This can be done several ways, as described in redefine buit-in php functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you know of any practical use of If-Unmodified-Since in the wild? From the
I have a properties file, which, when unmodified has the following line: worker.list= I
If I point to: mywebsite.com/search and there is a file called search.php or search.html
I receive some xml-files with embedded base64-encoded images, that I need to decode and
i have this script which i will post absolutely unmodified: <? chdir(data); $files =
When versioning or optimizing file backups one idea is to use only the delta
Background: I have a winforms app written in C# that converts xlsx files to
GetFileAttributesEx returns the date that the filesystem returns, unmodified. NTFS stores dates in UTC,
I have a html/javascript web page that I need to run unmodified on APEX
I have patch file describing changes to multiple files to apply to the contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.