• This works for me. It's based on the fact that addr is zero when a file does not exist. When a file exists addr is not zero but points to an address in Storage.

    var Storage = require("Storage");
    
    l=Storage.list();
    print(l);
    
    function exists(name){
      return Boolean(Storage.open(name,"r").addr);
    }
    
    print(exists("news.txt"));
    print(exists("nonews.txt"));
    

    The output is:

    [
    "news.txt\1",
    "weath0.txt\1",
    "weath1.txt\1",
    "stocks.txt\1",
    "messages.txt\1"
    ]
    true
    false

About

Avatar for gerardwr @gerardwr started