Thread: Bypass delete confirmation and trigger delete command directly

  1. #1
    Registered User
    Join Date
    Sep 2017
    Posts
    3

    Bypass delete confirmation and trigger delete command directly

    Hello, I want to bypass delete confirmation in other words trigger delete command without confirmation. How can I do this? Full code is in the attachment.


    Code:
    /* share code for file and directory deletion, saves space */
    static int delete_file_dir(void)
    {
        if (confirm_delete(selected_file) != YESNO_YES) {
            return 1;
        }
    
        clear_display(true);
        splash(HZ/2, str(LANG_DELETING));
    
        int rc = -1;
    
        if (selected_file_attr & ATTR_DIRECTORY) { /* true if directory */
            struct dirrecurse_params parm;
            parm.append = strlcpy(parm.path, selected_file, sizeof (parm.path));
    
            if (parm.append < sizeof (parm.path)) {
                cpu_boost(true);
                rc = remove_dir(&parm);
                cpu_boost(false);
            }
        } else {
            rc = remove(selected_file);
        }
    
        if (rc < OPRC_SUCCESS) {
            splash_failed(LANG_DELETE);
        } else if (rc == OPRC_CANCELLED) {
            splash_cancelled();
        }
    
        if (rc != OPRC_NOOP) {
            /* Could have failed after some but not all needed changes; reload */
            onplay_result = ONPLAY_RELOAD_DIR;
        }
    
        return 1;
    }
    Attached Files Attached Files

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Come on, this is easy... See lines #4, #5 and #6? Just delete them.
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Sep 2017
    Posts
    3
    I did it but when compile, I get error which stops the compile process because of this file. Actually this is Rockbox source code. I try to get rid of confirmation dialogue for faster & easier delete. Maybe there is alternative way to fool compiler without delete those lines?
    BTW previusly I had removed and modified some parts of this file and compiler hadn't throw any error.
    Last edited by seamoon; 09-06-2017 at 02:38 PM.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    What are the errors?
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Sep 2017
    Posts
    3
    I have also deleted this part on the same file and it worked. Thank you very much for your interest

    Code:
    static int confirm_delete(const char *file)
    {
        const char *lines[] = { ID2P(LANG_REALLY_DELETE), file };
        const char *yes_lines[] = { ID2P(LANG_DELETING), file };
        const struct text_message message = { lines, 2 };
        const struct text_message yes_message = { yes_lines, 2 };
        return gui_syncyesno_run(&message, &yes_message, NULL);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. List - Why my delete function doesn't delete?
    By juanjuanjuan in forum C Programming
    Replies: 7
    Last Post: 12-09-2014, 10:10 PM
  2. Delete confirmation fialog Registry Key
    By Mastadex in forum Windows Programming
    Replies: 3
    Last Post: 05-30-2008, 09:48 AM
  3. Concerning delete/delete[] at program exit
    By laserlight in forum C++ Programming
    Replies: 58
    Last Post: 01-09-2008, 01:40 PM
  4. Replies: 17
    Last Post: 11-16-2006, 09:06 PM
  5. using delete to delete an array
    By iain in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2002, 03:53 PM

Tags for this Thread