예제 #1
0
        public string GetNextFileName(string file, ICameraDevice device, string tempfile)
        {
            lock (_locker)
            {
                var ext = Path.GetExtension(file);
                if (ext == ".MOV")
                {
                    ext = ".mp4";
                }

                if (string.IsNullOrEmpty(ext))
                {
                    ext = ".nef";
                }
                if (!string.IsNullOrEmpty(_lastFilename) && RawExtensions.Contains(ext.ToLower()) &&
                    !RawExtensions.Contains(Path.GetExtension(_lastFilename).ToLower()))
                {
                    string rawfile = Path.Combine(Folder,
                                                  FormatFileName(device, ext, tempfile, false) + (!ext.StartsWith(".") ? "." : "") +
                                                  ext);
                    if (!File.Exists(rawfile))
                    {
                        return(rawfile);
                    }
                }

                string fileName = Path.Combine(Folder,
                                               FormatFileName(device, file, tempfile) + (!ext.StartsWith(".") ? "." : "") + ext);

                if (File.Exists(fileName) && !AllowOverWrite)
                {
                    // the template should contain a counter type tag
                    if (!FileNameTemplate.Contains("[Counter") && !AllowOverWrite)
                    {
                        FileNameTemplate += "[Counter 4 digit]";
                    }
                    return(GetNextFileName(file, device, tempfile));
                }
                _lastFilename = fileName;
                return(fileName);
            }
        }
예제 #2
0
 /// <summary>
 /// 指定されたファイルがログファイルとして使用できるかの判定を行う
 /// </summary>
 /// <param name="filepath"></param>
 /// <returns></returns>
 private bool IsValidLogFile(string filepath)
 {
     if (File.Exists(filepath))
     {
         FileInfo fi = new FileInfo(filepath);
         // 最大サイズより小さければ追記書き込みできるので OK
         if (fi.Length < MaxSize)
         {
             return(true);
         }
         // 最大サイズ以上でもサフィックスをサポートをしていない場合はOK
         if (!FileNameTemplate.Contains(SuffixPlaceHolder))
         {
             return(true);
         }
         // そうでない場合はNG
         return(false);
     }
     return(true);
 }