1 /***************************************************************************
2 *
3 * $Header: /usr/local/cvsroot/utils/ytree/filespec.c,v 1.13 2005/01/22 16:32:29 werner Exp $
4 *
5 * Setzt neue Datei-Spezifikation
6 *
7 ***************************************************************************/
8
9
10 #include "ytree.h"
11
12
13
14
SetFileSpec(char * file_spec)15 int SetFileSpec(char *file_spec)
16 {
17 if( SetMatchSpec( file_spec ) )
18 {
19 return( 1 );
20 }
21
22 statistic.disk_matching_files = 0L;
23 statistic.disk_matching_bytes = 0L;
24
25 SetMatchingParam( statistic.tree );
26
27 return( 0 );
28 }
29
30
31
32
SetMatchingParam(DirEntry * dir_entry)33 void SetMatchingParam(DirEntry *dir_entry)
34 {
35 DirEntry *de_ptr;
36 FileEntry *fe_ptr;
37 unsigned long matching_files;
38 LONGLONG matching_bytes;
39
40 for( de_ptr = dir_entry; de_ptr; de_ptr = de_ptr->next )
41 {
42 matching_files = 0L;
43 matching_bytes = 0L;
44
45 for( fe_ptr = de_ptr->file; fe_ptr; fe_ptr = fe_ptr->next )
46 {
47 if( Match( fe_ptr->name ) )
48 {
49 matching_files++;
50 matching_bytes += fe_ptr->stat_struct.st_size;
51 fe_ptr->matching = TRUE;
52 }
53 else
54 {
55 fe_ptr->matching = FALSE;
56 }
57 }
58
59 de_ptr->matching_files = matching_files;
60 de_ptr->matching_bytes = matching_bytes;
61
62 statistic.disk_matching_files += matching_files;
63 statistic.disk_matching_bytes += matching_bytes;
64
65 if( de_ptr->sub_tree )
66 {
67 SetMatchingParam( de_ptr->sub_tree );
68 }
69 }
70 }
71
72
73
74 /***************************************************************>>
75 ReadFileSpec.
76 Take in the user-specified new filespec.
77 As modified, it defaults to '*'; the original version offered the
78 current value as default, but that's just an up-arrow away.
79 Returns 0 on success, -1 on failure (empty string).
80 <<***************************************************************/
81
ReadFileSpec(void)82 int ReadFileSpec(void)
83 {
84 int result = -1;
85
86 char buffer[FILE_SPEC_LENGTH * 2 + 1];
87
88 ClearHelp();
89
90 (void) strcpy( buffer, "*" );
91 MvAddStr( LINES - 2, 1, "New filespec:" );
92 if( InputString( buffer, LINES - 2, 15, 0, FILE_SPEC_LENGTH, "\r\033" ) == CR )
93 {
94 if( SetFileSpec( buffer ) )
95 {
96 MESSAGE( "Invalid Filespec" );
97 }
98 else
99 {
100 (void) strcpy( statistic.file_spec, buffer );
101 result = 0;
102 }
103 }
104 move( LINES - 2, 1 ); clrtoeol();
105 return(result);
106 }
107
108
109