<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_filename(self, filename, filesystem=False, convert=False, subpath=''):

 """
 Get the filename according to self.to_path, and if filesystem is False
 then return unicode filename, otherwise return filesystem encoded filename
 
 @param filename: relative filename, it'll be combine with self.to_path
 @param filesystem: if True, then encoding the filename to filesystem
 @param convert: if True, then convert filename with FilenameConverter class
 @param subpath: sub folder in to_path
 """

        from uliweb.utils.common import safe_unicode
        
        #make sure the filename is unicode
        s = settings.GLOBAL
        if convert:
            _p, _f = os.path.split(filename)
            _filename = os.path.join(_p, self.filename_convert(_f))
        else:
            _filename = filename
        nfile = safe_unicode(_filename, s.HTMLPAGE_ENCODING)

        if subpath:
            paths = [application_path(self.to_path), subpath, nfile]
        else:
            paths = [application_path(self.to_path), nfile]
        f = os.path.normpath(os.path.join(*paths)).replace('\\', '/')
    
        if filesystem:
            return files.encode_filename(f, to_encoding=s.FILESYSTEM_ENCODING)
        return f