~martin-decky/helenos/rcu

« back to all changes in this revision

Viewing changes to tools/mkfat.py

replace illegal 8+3 characters with underscore to be consistent with the HelenOS FAT driver

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
        "Filter FAT legal characters"
190
190
        
191
191
        filtered_name = ''
192
 
        
193
 
        for char in name.encode('ascii', 'ignore').upper():
194
 
                if not char in lchars:
195
 
                        continue
196
 
                
197
 
                filtered_name += char
198
 
        
199
 
        return filtered_name
 
192
        filtered = False
 
193
        
 
194
        for char in name.encode('ascii', 'replace').upper():
 
195
                if char in lchars:
 
196
                        filtered_name += char
 
197
                else:
 
198
                        filtered_name += b'_'
 
199
                        filtered = True
 
200
        
 
201
        return (filtered_name, filtered)
200
202
 
201
203
def fat_name83(name, name83_list):
202
204
        "Create a 8.3 name for the given name"
203
205
        
204
 
        ascii_name = fat_lchars(name)
 
206
        ascii_name, lfn = fat_lchars(name)
205
207
        ascii_parts = ascii_name.split('.')
206
208
        
207
209
        short_name = ''
208
210
        short_ext = ''
209
 
        lfn = False
210
211
        
211
212
        if len(ascii_name) > 11:
212
213
                lfn = True