Blender  V2.93
file_ops.c File Reference
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLO_readfile.h"
#include "BKE_appdir.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "ED_asset.h"
#include "ED_fileselect.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "UI_view2d.h"
#include "WM_api.h"
#include "WM_types.h"
#include "file_intern.h"
#include "filelist.h"
#include "fsmenu.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

Box Select Operator
static int file_box_select_find_last_selected (SpaceFile *sfile, ARegion *region, const FileSelection *sel, const int mouse_xy[2])
 
static int file_box_select_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static int file_box_select_exec (bContext *C, wmOperator *op)
 
void FILE_OT_select_box (wmOperatorType *ot)
 
Select Pick Operator
static int file_select_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void FILE_OT_select (wmOperatorType *ot)
 
Select Walk Operator
static bool file_walk_select_selection_set (wmWindow *win, ARegion *region, SpaceFile *sfile, const int direction, const int numfiles, const int active_old, const int active_new, const int other_site, const bool has_selection, const bool extend, const bool fill)
 
static bool file_walk_select_do (bContext *C, SpaceFile *sfile, FileSelectParams *params, const int direction, const bool extend, const bool fill)
 
static int file_walk_select_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
void FILE_OT_select_walk (wmOperatorType *ot)
 
Select All Operator
static int file_select_all_exec (bContext *C, wmOperator *op)
 
void FILE_OT_select_all (wmOperatorType *ot)
 
View Selected Operator
static int file_view_selected_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_view_selected (wmOperatorType *ot)
 
Select Bookmark Operator
static int bookmark_select_exec (bContext *C, wmOperator *op)
 
void FILE_OT_select_bookmark (wmOperatorType *ot)
 
Add Bookmark Operator
static int bookmark_add_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_bookmark_add (wmOperatorType *ot)
 
Delete Bookmark Operator
static int bookmark_delete_exec (bContext *C, wmOperator *op)
 
void FILE_OT_bookmark_delete (wmOperatorType *ot)
 
Cleanup Bookmark Operator
static int bookmark_cleanup_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_bookmark_cleanup (wmOperatorType *ot)
 
Reset Recent Blend Files Operator
static int reset_recent_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_reset_recent (wmOperatorType *ot)
 
Highlight File Operator
int file_highlight_set (SpaceFile *sfile, ARegion *region, int mx, int my)
 
static int file_highlight_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
void FILE_OT_highlight (struct wmOperatorType *ot)
 
Sort from Column Operator
static int file_column_sort_ui_context_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
void FILE_OT_sort_column_ui_context (wmOperatorType *ot)
 
Cancel File Selector Operator
static bool file_operator_poll (bContext *C)
 
static int file_cancel_exec (bContext *C, wmOperator *UNUSED(unused))
 
void FILE_OT_cancel (struct wmOperatorType *ot)
 
Operator Utilities
void file_sfile_to_operator_ex (Main *bmain, wmOperator *op, SpaceFile *sfile, char *filepath)
 
void file_sfile_to_operator (Main *bmain, wmOperator *op, SpaceFile *sfile)
 
void file_operator_to_sfile (Main *bmain, SpaceFile *sfile, wmOperator *op)
 
void file_sfile_filepath_set (SpaceFile *sfile, const char *filepath)
 
void file_draw_check_ex (bContext *C, ScrArea *area)
 
void file_draw_check (bContext *C)
 
void file_draw_check_cb (bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
 
bool file_draw_check_exists (SpaceFile *sfile)
 
Execute File Window Operator
static int file_exec (bContext *C, wmOperator *exec_op)
 
static int file_exec_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void FILE_OT_execute (struct wmOperatorType *ot)
 
Refresh File List Operator
static int file_refresh_exec (bContext *C, wmOperator *UNUSED(unused))
 
void FILE_OT_refresh (struct wmOperatorType *ot)
 
static void file_expand_directory (bContext *C)
 
void file_directory_enter_handle (bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but))
 
void file_filename_enter_handle (bContext *C, void *UNUSED(arg_unused), void *arg_but)
 
Navigate Parent Operator
static int file_parent_exec (bContext *C, wmOperator *UNUSED(unused))
 
void FILE_OT_parent (struct wmOperatorType *ot)
 
Navigate Previous Operator
static int file_previous_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_previous (struct wmOperatorType *ot)
 
Navigate Next Operator
static int file_next_exec (bContext *C, wmOperator *UNUSED(unused))
 
void FILE_OT_next (struct wmOperatorType *ot)
 
Smooth Scroll Operator
static int file_smoothscroll_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
void FILE_OT_smoothscroll (wmOperatorType *ot)
 
File Selector Drop Operator
static int filepath_drop_exec (bContext *C, wmOperator *op)
 
void FILE_OT_filepath_drop (wmOperatorType *ot)
 
New Directory Operator
static int new_folder_path (const char *parent, char *folder, char *name)
 
static int file_directory_new_exec (bContext *C, wmOperator *op)
 
void FILE_OT_directory_new (struct wmOperatorType *ot)
 
Toggle Show Hidden Files Operator
static int file_hidedot_exec (bContext *C, wmOperator *UNUSED(unused))
 
void FILE_OT_hidedot (struct wmOperatorType *ot)
 
Increment Filename Operator
static bool file_filenum_poll (bContext *C)
 
static void filenum_newname (char *name, size_t name_size, int add)
 
static int file_filenum_exec (bContext *C, wmOperator *op)
 
void FILE_OT_filenum (struct wmOperatorType *ot)
 
Rename File/Directory Operator
static void file_rename_state_activate (SpaceFile *sfile, int file_idx, bool require_selected)
 
static int file_rename_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
 
static int file_rename_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_rename (struct wmOperatorType *ot)
 
Delete File Operator
static bool file_delete_poll (bContext *C)
 
static bool file_delete_single (const FileSelectParams *params, FileDirEntry *file, const char **r_error_message)
 
static int file_delete_exec (bContext *C, wmOperator *op)
 
void FILE_OT_delete (struct wmOperatorType *ot)
 
Enter Filter Text Operator
static int file_start_filter_exec (bContext *C, wmOperator *UNUSED(op))
 
void FILE_OT_start_filter (struct wmOperatorType *ot)
 
Macro Operators
void ED_operatormacros_file (void)
 

File Selection Utilities

enum  FileSelect { FILE_SELECT_NOTHING = 0 , FILE_SELECT_DIR = 1 , FILE_SELECT_FILE = 2 }
 
typedef enum FileSelect FileSelect
 
static FileSelection find_file_mouse_rect (SpaceFile *sfile, ARegion *region, const rcti *rect_region)
 
static void file_deselect_all (SpaceFile *sfile, uint flag)
 
static void clamp_to_filelist (int numfiles, FileSelection *sel)
 
static FileSelection file_selection_get (bContext *C, const rcti *rect, bool fill)
 
static FileSelect file_select_do (bContext *C, int selected_idx, bool do_diropen)
 
static bool file_is_any_selected (struct FileList *files)
 
static FileSelection file_current_selection_range_get (struct FileList *files)
 
static void file_ensure_inside_viewbounds (ARegion *region, SpaceFile *sfile, const int file)
 
static void file_ensure_selection_inside_viewbounds (ARegion *region, SpaceFile *sfile, FileSelection *sel)
 
static FileSelect file_select (bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen)
 

Reorder Bookmark Operator

enum  { FILE_BOOKMARK_MOVE_TOP = -2 , FILE_BOOKMARK_MOVE_UP = -1 , FILE_BOOKMARK_MOVE_DOWN = 1 , FILE_BOOKMARK_MOVE_BOTTOM = 2 }
 
static int bookmark_move_exec (bContext *C, wmOperator *op)
 
static bool file_bookmark_move_poll (bContext *C)
 
void FILE_OT_bookmark_move (wmOperatorType *ot)
 

Typedef Documentation

◆ FileSelect

typedef enum FileSelect FileSelect

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FILE_BOOKMARK_MOVE_TOP 
FILE_BOOKMARK_MOVE_UP 
FILE_BOOKMARK_MOVE_DOWN 
FILE_BOOKMARK_MOVE_BOTTOM 

Definition at line 1221 of file file_ops.c.

◆ FileSelect

enum FileSelect
Enumerator
FILE_SELECT_NOTHING 
FILE_SELECT_DIR 
FILE_SELECT_FILE 

Definition at line 116 of file file_ops.c.

Function Documentation

◆ bookmark_add_exec()

static int bookmark_add_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ bookmark_cleanup_exec()

static int bookmark_cleanup_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ bookmark_delete_exec()

static int bookmark_delete_exec ( bContext C,
wmOperator op 
)
static

◆ bookmark_move_exec()

static int bookmark_move_exec ( bContext C,
wmOperator op 
)
static

◆ bookmark_select_exec()

static int bookmark_select_exec ( bContext C,
wmOperator op 
)
static

◆ clamp_to_filelist()

static void clamp_to_filelist ( int  numfiles,
FileSelection sel 
)
static

Definition at line 122 of file file_ops.c.

References FileSelection::first, and FileSelection::last.

Referenced by file_selection_get().

◆ ED_operatormacros_file()

void ED_operatormacros_file ( void  )

Definition at line 2910 of file file_ops.c.

Referenced by ED_spacemacros_init().

◆ file_bookmark_move_poll()

static bool file_bookmark_move_poll ( bContext C)
static

Definition at line 1283 of file file_ops.c.

References SpaceFile::bookmarknr, C, and CTX_wm_space_file().

Referenced by FILE_OT_bookmark_move().

◆ file_box_select_exec()

static int file_box_select_exec ( bContext C,
wmOperator op 
)
static

◆ file_box_select_find_last_selected()

static int file_box_select_find_last_selected ( SpaceFile sfile,
ARegion region,
const FileSelection sel,
const int  mouse_xy[2] 
)
static

◆ file_box_select_modal()

static int file_box_select_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ file_cancel_exec()

static int file_cancel_exec ( bContext C,
wmOperator UNUSEDunused 
)
static

◆ file_column_sort_ui_context_invoke()

static int file_column_sort_ui_context_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ file_current_selection_range_get()

static FileSelection file_current_selection_range_get ( struct FileList files)
static

◆ file_delete_exec()

static int file_delete_exec ( bContext C,
wmOperator op 
)
static

◆ file_delete_poll()

static bool file_delete_poll ( bContext C)
static

◆ file_delete_single()

static bool file_delete_single ( const FileSelectParams params,
FileDirEntry file,
const char **  r_error_message 
)
static

◆ file_deselect_all()

static void file_deselect_all ( SpaceFile sfile,
uint  flag 
)
static

◆ file_directory_enter_handle()

void file_directory_enter_handle ( bContext C,
void *  UNUSEDarg_unused,
void *  UNUSEDarg_but 
)

◆ file_directory_new_exec()

static int file_directory_new_exec ( bContext C,
wmOperator op 
)
static

◆ file_draw_check()

void file_draw_check ( bContext C)

◆ file_draw_check_cb()

void file_draw_check_cb ( bContext C,
void *  UNUSEDarg1,
void *  UNUSEDarg2 
)

Definition at line 1695 of file file_ops.c.

References C, and file_draw_check().

◆ file_draw_check_ex()

void file_draw_check_ex ( bContext C,
ScrArea area 
)

◆ file_draw_check_exists()

bool file_draw_check_exists ( SpaceFile sfile)

◆ file_ensure_inside_viewbounds()

static void file_ensure_inside_viewbounds ( ARegion region,
SpaceFile sfile,
const int  file 
)
static

◆ file_ensure_selection_inside_viewbounds()

static void file_ensure_selection_inside_viewbounds ( ARegion region,
SpaceFile sfile,
FileSelection sel 
)
static

◆ file_exec()

static int file_exec ( bContext C,
wmOperator exec_op 
)
static

◆ file_exec_invoke()

static int file_exec_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ file_expand_directory()

static void file_expand_directory ( bContext C)
static

◆ file_filename_enter_handle()

void file_filename_enter_handle ( bContext C,
void *  UNUSEDarg_unused,
void *  arg_but 
)

◆ file_filenum_exec()

static int file_filenum_exec ( bContext C,
wmOperator op 
)
static

◆ file_filenum_poll()

static bool file_filenum_poll ( bContext C)
static

◆ file_hidedot_exec()

static int file_hidedot_exec ( bContext C,
wmOperator UNUSEDunused 
)
static

◆ file_highlight_invoke()

static int file_highlight_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ file_highlight_set()

int file_highlight_set ( SpaceFile sfile,
ARegion region,
int  mx,
int  my 
)

◆ file_is_any_selected()

static bool file_is_any_selected ( struct FileList files)
static
Warning
: loops over all files so better use cautiously

Definition at line 244 of file file_ops.c.

References CHECK_ALL, filelist_entry_select_index_get(), and filelist_files_ensure().

Referenced by file_select(), file_select_all_exec(), and file_walk_select_do().

◆ file_next_exec()

static int file_next_exec ( bContext C,
wmOperator UNUSEDunused 
)
static

◆ file_operator_poll()

static bool file_operator_poll ( bContext C)
static

Definition at line 1489 of file file_ops.c.

References C, CTX_wm_space_file(), ED_operator_file_active(), and SpaceFile::op.

Referenced by FILE_OT_cancel().

◆ file_operator_to_sfile()

void file_operator_to_sfile ( Main bmain,
SpaceFile sfile,
wmOperator op 
)

◆ FILE_OT_bookmark_add()

void FILE_OT_bookmark_add ( wmOperatorType ot)

◆ FILE_OT_bookmark_cleanup()

void FILE_OT_bookmark_cleanup ( wmOperatorType ot)

◆ FILE_OT_bookmark_delete()

void FILE_OT_bookmark_delete ( wmOperatorType ot)

◆ FILE_OT_bookmark_move()

void FILE_OT_bookmark_move ( wmOperatorType ot)

◆ FILE_OT_cancel()

void FILE_OT_cancel ( struct wmOperatorType ot)

◆ FILE_OT_delete()

void FILE_OT_delete ( struct wmOperatorType ot)

◆ FILE_OT_directory_new()

void FILE_OT_directory_new ( struct wmOperatorType ot)

◆ FILE_OT_execute()

void FILE_OT_execute ( struct wmOperatorType ot)

◆ FILE_OT_filenum()

void FILE_OT_filenum ( struct wmOperatorType ot)

◆ FILE_OT_filepath_drop()

void FILE_OT_filepath_drop ( wmOperatorType ot)

◆ FILE_OT_hidedot()

void FILE_OT_hidedot ( struct wmOperatorType ot)

◆ FILE_OT_highlight()

void FILE_OT_highlight ( struct wmOperatorType ot)

◆ FILE_OT_next()

void FILE_OT_next ( struct wmOperatorType ot)

◆ FILE_OT_parent()

void FILE_OT_parent ( struct wmOperatorType ot)

◆ FILE_OT_previous()

void FILE_OT_previous ( struct wmOperatorType ot)

◆ FILE_OT_refresh()

void FILE_OT_refresh ( struct wmOperatorType ot)

◆ FILE_OT_rename()

void FILE_OT_rename ( struct wmOperatorType ot)

◆ FILE_OT_reset_recent()

void FILE_OT_reset_recent ( wmOperatorType ot)

◆ FILE_OT_select()

void FILE_OT_select ( wmOperatorType ot)

◆ FILE_OT_select_all()

void FILE_OT_select_all ( wmOperatorType ot)

◆ FILE_OT_select_bookmark()

void FILE_OT_select_bookmark ( wmOperatorType ot)

◆ FILE_OT_select_box()

void FILE_OT_select_box ( wmOperatorType ot)

◆ FILE_OT_select_walk()

void FILE_OT_select_walk ( wmOperatorType ot)

◆ FILE_OT_smoothscroll()

void FILE_OT_smoothscroll ( wmOperatorType ot)

◆ FILE_OT_sort_column_ui_context()

void FILE_OT_sort_column_ui_context ( wmOperatorType ot)

◆ FILE_OT_start_filter()

void FILE_OT_start_filter ( struct wmOperatorType ot)

◆ FILE_OT_view_selected()

void FILE_OT_view_selected ( wmOperatorType ot)

◆ file_parent_exec()

static int file_parent_exec ( bContext C,
wmOperator UNUSEDunused 
)
static

◆ file_previous_exec()

static int file_previous_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ file_refresh_exec()

static int file_refresh_exec ( bContext C,
wmOperator UNUSEDunused 
)
static

◆ file_rename_exec()

static int file_rename_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ file_rename_invoke()

static int file_rename_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent UNUSEDevent 
)
static

◆ file_rename_state_activate()

static void file_rename_state_activate ( SpaceFile sfile,
int  file_idx,
bool  require_selected 
)
static

◆ file_select()

static FileSelect file_select ( bContext C,
const rcti rect,
FileSelType  select,
bool  fill,
bool  do_diropen 
)
static

◆ file_select_all_exec()

static int file_select_all_exec ( bContext C,
wmOperator op 
)
static

◆ file_select_do()

static FileSelect file_select_do ( bContext C,
int  selected_idx,
bool  do_diropen 
)
static

◆ file_select_invoke()

static int file_select_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ file_selection_get()

static FileSelection file_selection_get ( bContext C,
const rcti rect,
bool  fill 
)
static

◆ file_sfile_filepath_set()

void file_sfile_filepath_set ( SpaceFile sfile,
const char *  filepath 
)

Use to set the file selector path from some arbitrary source.

Definition at line 1645 of file file_ops.c.

References BLI_assert, BLI_exists(), BLI_is_dir(), BLI_split_dir_part(), BLI_split_dirfile(), BLI_strncpy(), ED_fileselect_get_active_params(), FILE_DIRSEL_ONLY, and params.

Referenced by filepath_drop_exec().

◆ file_sfile_to_operator()

void file_sfile_to_operator ( Main bmain,
wmOperator op,
SpaceFile sfile 
)

Definition at line 1607 of file file_ops.c.

References FILE_MAX, and file_sfile_to_operator_ex().

Referenced by file_draw_check_ex(), and filepath_drop_exec().

◆ file_sfile_to_operator_ex()

void file_sfile_to_operator_ex ( Main bmain,
wmOperator op,
SpaceFile sfile,
char *  filepath 
)

◆ file_smoothscroll_invoke()

static int file_smoothscroll_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ file_start_filter_exec()

static int file_start_filter_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ file_view_selected_exec()

static int file_view_selected_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ file_walk_select_do()

static bool file_walk_select_do ( bContext C,
SpaceFile sfile,
FileSelectParams params,
const int  direction,
const bool  extend,
const bool  fill 
)
static

◆ file_walk_select_invoke()

static int file_walk_select_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ file_walk_select_selection_set()

static bool file_walk_select_selection_set ( wmWindow win,
ARegion region,
SpaceFile sfile,
const int  direction,
const int  numfiles,
const int  active_old,
const int  active_new,
const int  other_site,
const bool  has_selection,
const bool  extend,
const bool  fill 
)
static

◆ filenum_newname()

static void filenum_newname ( char *  name,
size_t  name_size,
int  add 
)
static

Looks for a string of digits within name (using BLI_path_sequence_decode) and adjusts it by add.

Definition at line 2625 of file file_ops.c.

References add(), BLI_path_sequence_decode(), BLI_path_sequence_encode(), BLI_strncpy(), KDL::exp(), and FILE_MAXFILE.

Referenced by file_filenum_exec().

◆ filepath_drop_exec()

static int filepath_drop_exec ( bContext C,
wmOperator op 
)
static

◆ find_file_mouse_rect()

static FileSelection find_file_mouse_rect ( SpaceFile sfile,
ARegion region,
const rcti rect_region 
)
static

◆ new_folder_path()

static int new_folder_path ( const char *  parent,
char *  folder,
char *  name 
)
static

Create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name.

Definition at line 2242 of file file_ops.c.

References BLI_exists(), BLI_join_dirfile(), BLI_snprintf(), BLI_strncpy(), FILE_MAX, FILE_MAXFILE, and len.

Referenced by file_directory_new_exec().

◆ reset_recent_exec()

static int reset_recent_exec ( bContext C,
wmOperator UNUSEDop 
)
static