If the file can't be found -- it will be retrieved from the server.
5509
def get_file(self, latitude, longitude):
        
        file_name = self.get_file_name(latitude, longitude)

        if not file_name:
            return None

        if (file_name in self.files):
            return self.files[file_name]
        else:
            data = self.retrieve_or_load_file_data(file_name)
            if not data:
                return None

            result = GeoElevationFile(file_name, data, self)

            # Store file (if in batch mode, just keep most recent)
            if self.batch_mode:
                self.files = {file_name: result}
            else:
                self.files[file_name] = result

            return result
614184
function tryServeWithBrotli(shouldTryGzip) {
      fs.stat(brotliFile, (err, stat) => {
        if (!err && stat.isFile()) {
          file = brotliFile;
          serve(stat);
        } else if (shouldTryGzip) {
          tryServeWithGzip();
        } else {
          statFile();
        }
      });
    }
1044606
function safeReadFileSync (fileName, options) {
    verifyFileName (fileName);
    
    // if fileName exists, verify it is a file
    var info = getFileInfo (fileName);
    if ((info.exists) && (info.isFile === false)) {
        var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
        throw new SafeFileError (cc.IS_NOT_A_FILE, message);
    }

    // get state, if auto-recovery required, perform recovery
    var state = getState (fileName);
    if (state.status === cc.SAFE_RECOVERABLE) {
        performRecovery (state, true);
    }

    // perform read on file
    return (readFileSync (fileName, options));
}
59014
def get(self, filename, reset=False):
        
        if filename in self.files and not reset:
            return self.files[filename]

        # load a single file, and process
        files = {}
        path = os.path.join(self.source, filename)
        files[filename] = frontmatter.load(path, 
            filename=filename,
            slug=os.path.splitext(filename)[0])

        # call middleware
        for func in self.middleware:
            func(files, self)

        # cache the processed post
        self.files.update(files)

        # return just the post
        try:
            return files[filename]
        except KeyError:
            raise PostNotFound('{0} not found'.format(filename))
362679
def get_file(self,
                 path,
                 dest='',
                 makedirs=False,
                 saltenv='base',
                 gzip=None,
                 cachedir=None):
        '''
        
        '''
        raise NotImplementedError
773048
public void handleGet(HttpRequest request,
                          HttpResponse response,
                          String pathInContext,
                          String pathParams,
                          Resource resource)
        throws IOException
    {
        if(log.isDebugEnabled())log.debug("Looking for "+resource);
        
        if (resource!=null && resource.exists())
        {            
            // check if directory
            if (resource.isDirectory())
            {
                if (!pathInContext.endsWith("/") && !pathInContext.equals("/"))
                {
                    log.debug("Redirect to directory/");
                    
                    String q=request.getQuery();
                    StringBuffer buf=request.getRequestURL();
                    if (q!=null&&q.length()!=0)
                    {
                        buf.append('?');
                        buf.append(q);
                    }
                    response.setField(HttpFields.__Location, URI.addPaths(buf.toString(),"/"));
                    response.setStatus(302);
                    request.setHandled(true);
                    return;
                }
  
                // See if index file exists
                String welcome=getHttpContext().getWelcomeFile(resource);
                if (welcome!=null)
                {     
                    // Forward to the index
                    String ipath=URI.addPaths(pathInContext,welcome);
                    if (_redirectWelcomeFiles)
                    {
                        // Redirect to the index
                        ipath=URI.addPaths(getHttpContext().getContextPath(),ipath);
                        response.setContentLength(0);
                        response.sendRedirect(ipath);
                    }
                    else
                    {
                        URI uri=request.getURI();
                        uri.setPath(URI.addPaths(uri.getPath(),welcome));
                        getHttpContext().handle(ipath,pathParams,request,response);
                    }
                    return;
                }

                // Check modified dates
                if (!passConditionalHeaders(request,response,resource))
                    return;
                // If we got here, no forward to index took place
                sendDirectory(request,response,resource,pathInContext.length()>1);
            }
            // check if it is a file
            else if (resource.exists())
            {
                // Check modified dates
                if (!passConditionalHeaders(request,response,resource))
                    return;
                sendData(request,response,pathInContext,resource,true);
            }
            else
                // don't know what it is
                log.warn("Unknown file type");
        }
    }
1242077
@Override
  public synchronized int available() throws IOException {
    if (closed) {
      throw new IOException("Stream closed");
    }
    long length = getFileLength() - pos;
    
    if (!isUnderConstruction() || length > 0) {
      return (int) length;
    }
    
    long timeNow = System.currentTimeMillis();
    if (timeShowNoAvailableByte != NOT_WAITING_FOR_MORE_BYTES
        && timeNow - timeShowNoAvailableByte > timeoutGetAvailFromDatanode) {
      if (DFSClient.LOG.isDebugEnabled()) {
        DFSClient.LOG
            .debug("To calculate available(), refetch metedata for file " + src);
      }
      // To avoid the minor case that:
      // (1) we stick to a datanode with a replica with older generation stamp
      // (2) after reopening the stream because of failure the file length is
      // (temporarily) smaller than current pos
      // after available value stays to be zero for a while, we re-fetch all the
      // metadata from the name node.
      //
      // The default value of timeoutGetAvailFromDatanode is set to be
      // relatively long to minimize namenode traffic in the case that
      // the the file is kept open with no new data for a long time. This
      // time out is the time bound of update delay of available in corner
      // cases.
      openInfo();
      // Force not to reuse the current block reader
      blockEnd = -1;
      // Reset the refetch metadata timer
      timeShowNoAvailableByte = NOT_WAITING_FOR_MORE_BYTES;
    }

    // In the case that file length shrinks after connection failure,
    // this call might always return -1 without updating the length.
    // In this case, we also reply on get available time out mechanism to
    // eventually make sure the stream is reopened and the client can read
    // data from it.
    read(DFSClient.emptyByteArray, 0, 0);
    
    long availableBytes = getFileLength() - pos;

    if (availableBytes > 0) {
      timeShowNoAvailableByte = NOT_WAITING_FOR_MORE_BYTES;
    } else if (timeShowNoAvailableByte == NOT_WAITING_FOR_MORE_BYTES) {
      timeShowNoAvailableByte = timeNow;
    }

    // Since the client might reopen the file because of exceptions
    // and refetch file length from another data node and gets a file
    // length that is smaller than current position. In this case, instead
    // of returning a negative value, return 0.
    return Math.max(0,
        (int) (Math.min(availableBytes, (long) Integer.MAX_VALUE)));
  }
780361
def get_object_by_filename(self, request, filename):
        
        kw = dict()
        kw[self.file_field] = filename
        obj = self.get_queryset(request).filter(**kw).first()
        if not obj:
            raise Http404(_('File {} not found').format(filename))
        return self.get_object(request, obj.id)
55913
public void actionReplace() throws JspException {

        try {
            // get the file item from the multipart request
            Iterator<FileItem> i = getMultiPartFileItems().iterator();
            FileItem fi = null;
            while (i.hasNext()) {
                fi = i.next();
                if (fi.getName() != null) {
                    // found the file object, leave iteration
                    break;
                }
            }

            if (fi != null) {
                // get file object information
                long size = fi.getSize();
                long maxFileSizeBytes = OpenCms.getWorkplaceManager().getFileBytesMaxUploadSize(getCms());
                // check file size
                if ((maxFileSizeBytes > 0) && (size > maxFileSizeBytes)) {
                    // file size is larger than maximum allowed file size, throw an error
                    throw new CmsException(
                        Messages.get().container(
                            Messages.ERR_FILE_SIZE_TOO_LARGE_1,
                            new Long((maxFileSizeBytes / 1024))));
                }
                byte[] content = fi.get();
                fi.delete();

                // determine the resource type id from the resource to replace
                CmsResource res = getCms().readResource(getParamResource(), CmsResourceFilter.IGNORE_EXPIRATION);
                CmsFile file = getCms().readFile(res);
                byte[] contents = file.getContents();
                int resTypeId = res.getTypeId();
                // check the lock state and replace resource
                checkLock(getParamResource());
                try {
                    getCms().replaceResource(getParamResource(), resTypeId, content, null);
                } catch (CmsDbSqlException sqlExc) {
                    // SQL error, probably the file is too large for the database settings, restore old content
                    file.setContents(contents);
                    getCms().writeFile(file);
                    throw sqlExc;
                }
                // close dialog
                actionCloseDialog();
            } else {
                throw new CmsException(Messages.get().container(Messages.ERR_UPLOAD_FILE_NOT_FOUND_0));
            }
        } catch (Throwable e) {
            // error replacing file, show error dialog
            includeErrorpage(this, e);
        }
    }
301908
function tryFile(requestPath, isMain) {
  const rc = stat(requestPath);
  if (preserveSymlinks && !isMain) {
    return rc === 0 && path.resolve(requestPath);
  }
  return rc === 0 && toRealPath(requestPath);
}
1238366
def get(self, request, *args, **kwargs):
        
        private_file = self.get_private_file()

        if not self.can_access_file(private_file):
            return HttpResponseForbidden('Private storage access denied')

        if not private_file.exists():
            return self.serve_file_not_found(private_file)
        else:
            return self.serve_file(private_file)
389428
def check_existance(f):
    """"""
    if not opath.isfile(f):
        logging.error("Nanoget: File provided doesn't exist or the path is incorrect: {}".format(f))
        sys.exit("File provided doesn't exist or the path is incorrect: {}".format(f))
42680
def serve_file(self, load):
        '''
        
        '''
        ret = {'data': '',
               'dest': ''}

        if 'env' in load:
            # "env" is not supported; Use "saltenv".
            load.pop('env')

        if 'path' not in load or 'loc' not in load or 'saltenv' not in load:
            return ret
        if not isinstance(load['saltenv'], six.string_types):
            load['saltenv'] = six.text_type(load['saltenv'])

        fnd = self.find_file(load['path'], load['saltenv'])
        if not fnd.get('back'):
            return ret
        fstr = '{0}.serve_file'.format(fnd['back'])
        if fstr in self.servers:
            return self.servers[fstr](load, fnd)
        return ret
888733
function onRequest(request, response) {
  var filename = path.join(__dirname, request.url);

  // Serving server.js from cache. Useful for microbenchmarks.
  if (request.url === cachedUrl) {
    if (response.push) {
      // Also push down the client js, since it's possible if the requester wants
      // one, they want both.
      var push = response.push('/client.js');
      push.writeHead(200);
      fs.createReadStream(path.join(__dirname, '/client.js')).pipe(push);
    }
    response.end(cachedFile);
  }

  // Reading file from disk if it exists and is safe.
  else if ((filename.indexOf(__dirname) === 0) && fs.existsSync(filename) && fs.statSync(filename).isFile()) {
    response.writeHead(200);
    var fileStream = fs.createReadStream(filename);
    fileStream.pipe(response);
    fileStream.on('finish',response.end);
  }

  // Example for testing large (boundary-sized) frames.
  else if (request.url === "/largeframe") {
    response.writeHead(200);
    var body = 'a';
    for (var i = 0; i < 14; i++) {
      body += body;
    }
    body = body + 'a';
    response.end(body);
  }

  // Otherwise responding with 404.
  else {
    response.writeHead(404);
    response.end();
  }
}
511226
function tryServeWithGzip() {
      fs.stat(gzippedFile, (err, stat) => {
        if (!err && stat.isFile()) {
          hasGzipId12(gzippedFile, (gzipErr, isGzip) => {
            if (!gzipErr && isGzip) {
              file = gzippedFile;
              serve(stat);
            } else {
              statFile();
            }
          });
        } else {
          statFile();
        }
      });
    }
246620
def _get_file(self, fn, timeout=30):
        '''
        '''
        msg = FILE_MAP.get(fn, None)
        if msg is None:
            raise FileNotFoundError('Cannot get file {!r}. Available file '
                                    'requests are: {}'
                                    .format(fn, ', '.join(FILE_MAP.keys())))
        result = self._loop.run_until_complete(
            self._protocol.send_package(msg, timeout=timeout))
        return result
999195
def serve(self, filename):
        ''''''
        if not self.exists(filename):
            abort(404)
        return self.backend.serve(filename)