-- luafiler (c) 2006 mallchin, http://www.mallchin.com/luafm/
-- You are free to distribute this file without modifications.

function file_action(path, name, modifier)

  local vblankwait = 0

  if modifier == "execute" then

    -- update dir
    if is_dir(path, name) then
      System.currentDirectory(name)
      update_files()
    end

    -- render files
    render_filelist()

    -- render action info
    if is_dir(path, name) then
      render_statmsg("Changed into directory: " .. name, white)
    else
      render_statmsg("Execute file: " .. name, white)
--      if test_filetype(name, "lua") then
--        confirm_action = "dofile(\"" .. name .. "\")"
--        render_confirm("Run lua script?", white, false)
--      else
        render_alert("Unsupported filetype", white, false)
	vblankwait = 120
--      end
    end

  elseif modifier == "operation" then

    render_statmsg("File operations", white)

    -- render files
    render_filelist()

    -- render file operations
    selected_operation = 1
    render_file_operations(selected_operation)

  end

  -- flip screen
  screen.flip()
  screen.waitVblankStart(vblankwait)

end
