Hey sorry for the late reply,
Basically what Darkseed said. Have it prompt you that the file is marked as read only on disk and allow the user to overwrite it anyway.
A lot of text editors do this and it would be helpful for people using source control tools like perforce that set the read only flag on a file unless its checked out. Usually I just edit a file without checking it out and save it, Perforce then allows you to select a directory and click 'reconcile offline work' which will find any files that are different and check them out for you which is handy.
I spent about 10 - 15 minutes on the weekend playing around with stuff and managed to do a quick implementation myself by injecting the following code into 4coder_base_commands.cpp. It's not ideal but did the trick as a temp solution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 | CUSTOM_COMMAND_SIG(save)
{
auto view_summary = get_active_view(app, AccessOpen);
auto buff_summary = get_buffer(app, view_summary.buffer_id, AccessOpen);
if (buff_summary.exists)
{
const char* file_name = buff_summary.file_name;
DWORD attrib = GetFileAttributes(file_name);
if (attrib != INVALID_FILE_ATTRIBUTES)
{
const bool is_read_only = (attrib & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY;
if (is_read_only)
{
Query_Bar bar = { 0 };
bar.prompt = make_lit_string("You are trying a save a file marked as 'read only' overwrite anyway? (Y)es (N)o");
bar.string = null_string;
bool success = false;
if (start_query_bar(app, &bar, 0) != 0 )
{
while (true)
{
User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc);
if (in.abort)
{
return;
}
if (in.key.character == 'y' || in.key.character == 'Y')
{
success = true;
break;
}
else if (in.key.character == 'N' || in.key.character == 'n')
{
success = false;
break;
}
}
if (success)
{
attrib &= ~FILE_ATTRIBUTE_READONLY;
SetFileAttributes(file_name, attrib);
exec_command(app, cmdid_save);
}
else
{
end_query_bar(app, &bar, 0);
}
}
}
else
{
exec_command(app, cmdid_save);
}
}
}
}
|
It assumes you are working on windows, also I was trying to see if I could get the functionality similar to the prompt that asks if you want to close 4coder even though there are unsaved changes. There is a yes and no option which you can click with the mouse or select with the keyboard.
I tried to achieve this with query bars but I got a crash. I also stumbled across another forum post where Allen was saying the Query bars are a more of a hack than a more permanent solution.