1 //
2 // aegis - project change supervisor
3 // Copyright (C) 1999, 2002-2008, 2011, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at
8 // your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #include <common/ac/assert.h>
20 
21 #include <common/str_list.h>
22 #include <common/trace.h>
23 #include <libaegis/change/file.h>
24 #include <libaegis/os/isa/path_prefix.h>
25 
26 
27 void
change_file_directory_query(change::pointer cp,string_ty * file_name,string_list_ty * result_in,string_list_ty * result_out)28 change_file_directory_query(change::pointer cp, string_ty *file_name,
29     string_list_ty *result_in, string_list_ty *result_out)
30 {
31     fstate_ty       *fstate_data;
32     size_t                  j;
33     fstate_src_ty   *src_data;
34 
35     trace(("change_file_dir(cp = %p, file_name = \"%s\")\n{\n",
36         cp, file_name->str_text));
37     assert(result_in);
38     result_in->clear();
39     if (result_out)
40         result_out->clear();
41     fstate_data = cp->fstate_get();
42     assert(fstate_data->src);
43     for (j = 0; j < fstate_data->src->length; ++j)
44     {
45         src_data = fstate_data->src->list[j];
46         if (src_data->about_to_be_created_by && !src_data->deleted_by)
47             continue;
48         switch (src_data->usage)
49         {
50         case file_usage_build:
51             continue;
52 
53         case file_usage_source:
54         case file_usage_config:
55         case file_usage_test:
56         case file_usage_manual_test:
57             break;
58         }
59         if (os_isa_path_prefix(file_name, src_data->file_name))
60         {
61             if (!src_data->deleted_by)
62                 result_in->push_back(src_data->file_name);
63             else if (result_out)
64                 result_out->push_back(src_data->file_name);
65         }
66     }
67     trace(("}\n"));
68 }
69 
70 
71 // vim: set ts=8 sw=4 et :
72