Small refactoring

This commit is contained in:
Sanel Zukan 2008-10-02 12:16:04 +00:00
parent 865bbca053
commit 8a08b132ad
4 changed files with 19 additions and 20 deletions

View File

@ -308,6 +308,7 @@ int DesktopIcon::drag_icon_y(void) {
void DesktopIcon::rename(const char* str) {
if(!str)
return;
if(settings->name == str)
return;

View File

@ -311,3 +311,16 @@ char* get_basename(const char* path) {
return (char*)path;
}
bool is_temp_filename(const char* path) {
int len;
if(!path || path[0] == '\0' || path[0] == '.')
return true;
len = strlen(path);
if(path[len - 1] == '~')
return true;
return false;
}

View File

@ -41,5 +41,6 @@ void set_xoverlay_drawable(Fl_Window* win);
Pixmap create_mask(Fl_Image* img);
char* get_basename(const char* path);
bool is_temp_filename(const char* path);
#endif

View File

@ -914,6 +914,10 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
if(!do_dirwatch || !changed || flags == edelib::DW_REPORT_NONE)
return;
// skip temporary files
if(is_temp_filename(changed))
return;
if(trash_path == dir) {
bool is_empty = edelib::dir_empty(trash_path.c_str());
@ -932,17 +936,6 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
return;
}
/*
* Check first we don't get any temporary files (starting with '.'
* or ending with '~', like vim does when editing file). For now these
* are only conditions, but I will probably add them more when issues occured.
*
* FIXME: use strcmp() family ?
*/
edelib::String tmp(changed);
if(tmp.empty() || tmp[0] == '.' || tmp[tmp.length()-1] == '~')
return;
sleep(1);
if(flags == edelib::DW_REPORT_CREATE) {
@ -953,15 +946,6 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
return;
}
/*
* Uh; looks like kernel report event faster than file is created
* (in some cases). This can be bad for .desktop files when are copied
* (eg. on my machine after 'cp Home.desktop foo.desktop', will fail
* to load foo.desktop since it's content is not fully copied).
* Due that we stop for one sec (use usleep() ???)
*/
//sleep(1);
if(add_icon_by_path(changed, 0))
redraw();