Пример #1
0
        void find_first_file(BytePtr aName)
        {
            DirectoryInfo dir = new DirectoryInfo(dir_path);

            if (!dir.Exists)
            {
                return;
            }

            FileInfo[] files = dir.GetFiles();

            string name = aName.ToString();

            IEnumerator fenum = files.GetEnumerator();

            while (fenum.MoveNext() && (((FileInfo)fenum.Current).Name == "." || ((FileInfo)fenum.Current).Name == ".."))
            {
                ;
            }

            do
            {
                FileInfo fi = (FileInfo)fenum.Current;

                // Match found? Then copy real file name
                if (match(name, fi.Name))
                {
                    CharFunctions.strncpy(aName, fi.Name);
                    return;
                }
            } while (fenum.MoveNext());
        }
Пример #2
0
        unsafe void convert_filename(BytePtr srcname, BytePtr destname, ref FileAccessMode filemode, ref FileType filetype)
        {
            byte *p;

            // Search for ':', p points to first character after ':'
            if ((p = CharFunctions.strchr(srcname, ':')) != null)
            {
                p++;
            }
            else
            {
                p = srcname;
            }

            // Remaining string -> destname
            CharFunctions.strncpy(destname, srcname, p);

            // Look for mode parameters seperated by ','
            p = destname;
            while ((p = CharFunctions.strchr(p, ',')) != null)
            {
                // Cut string after the first ','
                *p++ = 0;
                switch ((Char)(*p))
                {
                case 'P':
                    filetype = FileType.FTYPE_PRG;
                    break;

                case 'S':
                    filetype = FileType.FTYPE_SEQ;
                    break;

                case 'U':
                    filetype = FileType.FTYPE_USR;
                    break;

                case 'L':
                    filetype = FileType.FTYPE_REL;
                    break;

                case 'R':
                    filemode = FileAccessMode.FMODE_READ;
                    break;

                case 'W':
                    filemode = FileAccessMode.FMODE_WRITE;
                    break;

                case 'A':
                    filemode = FileAccessMode.FMODE_APPEND;
                    break;
                }
            }
        }