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 8574695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:31:53+00:00 2026-06-11T19:31:53+00:00

Im trying to use the new HTML5 FileSystem API for creating/adding/deleting files with javascript.

  • 0

Im trying to use the new HTML5 FileSystem API for creating/adding/deleting files with javascript. (for use with a self-service cash desk)

current code:

var entries;
function onInitFs(fs) {
    fileSystem = fs;
    debug('Opened file system: ' + fs.name);
    loadFilelist();
    // The functions below execute before loadFilelist() is ready!
    setFileList(entries);
    showFilenames(entries);
}

function loadFilelist() {
    entries = [];
    var dirReader = fileSystem.root.createReader();
    readEntries();

    function readEntries() {
        dirReader.readEntries(function(results) {
            if (results.length > 0) {
                debug(results.length + " Files added to the filesystemFilelist");
                entries = entries.concat(toArray(results));
                entries.sort();
                readEntries();
            }else{
                debug(entries.length + " Files in the filesystemFilelist");
                //done
            }
        }, fileErrorHandler);
    };
}

/* For putting debug text in the debug screen (in this case its the console) */
function debug(content) {
    window.console.log(content);
}

The problem with this is that the function dirReader.readEntries(function (), callback) waits for a callback. Meanwhile the code that comes next already executes.
Ive looked it up in the File API and it seems the function only works with a callback

How can i prevent that the function calls

setFileList(entries);
showFilenames(entries);

execute before loadFilelist is done?

Thanks in advance

  • 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-06-11T19:31:54+00:00Added an answer on June 11, 2026 at 7:31 pm

    Currently im using a worker to do the synchronous work! Works perfect! I made a ‘command system thingy’ between the main and the worker scripts. I will post the basics if someone is interested! Barely anybody looked at this question so for now i only mark it as SOLVED

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

Sidebar

Related Questions

I'm trying to use the new OpenCV 2.0 API in MS Visual C++ 2008
I'm trying to use the new ASP.NET Web API to do the following: A
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
(I'm new to html5... so use small words) I'm trying to animate a scatterplot
I am trying to use the multiple upload attribute of HTML5 to upload files.
Hi HTML5 / css guru'es I'm trying to make use of some new features
I'm new to Javascript/jQuery and I'm trying to make a play button for HTML5
I am trying to use new Google Cloud Messaging system but I have some
I am trying to use the new Eventmanager of the Zend Framework 2. I
I am trying to use nunits new way of exception handling but I am

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.