コード例 #1
0
ファイル: client.c プロジェクト: jerridan/hooli_drive
// Recursively scans a specified directory, calculates file checksums, and
// adds the entries to a linked list
void scanHooliDir(char *dir, const int base_path_length, hooli_file** file, 
  int* count) 
{
  DIR* dirp;         // Pointer to directory stream
  struct dirent* dp; // Pointer to current object in directory stream

  // Open directory
  if(NULL == (dirp = opendir(dir))) {
    // If the directory can't be opened, log an error and move on
    syslog(LOG_WARNING, "Unable to open directory '%s'", dir);
    return;
  }

  // Iterate over files/folders in directory
  while(NULL != (dp = readdir(dirp))) {
    // Don't scan directories like '.' or '..'
    if(isCurrentOrParentDir(dp->d_name)) {
      continue;
    }

    // Scan subdirectories recursively
    if(DT_DIR == dp->d_type) {
      // Concatenate parent directory and current directory names
      char* current_path = getFullPathName(dir, dp->d_name, true);
      scanHooliDir(current_path, base_path_length, file, count);
      free(current_path);
    } else {
      // Concatenate parent directory and current directory names
      char* current_path = getFullPathName(dir, dp->d_name, false);
      // int file_length; // Length of file in bytes
      // char* buffer;    // Contents of file
      // readFileToBuffer(current_path, &buffer, &file_length);
      int checksum = calcChecksum(current_path);
      if(-1 != checksum) {
        // uLong checksum = calcChecksum(buffer, file_length); // checksum
        // Copy relative path to new string
        char* filepath = getStrCopy(current_path + base_path_length);
        // Add hooli_file entry
        addHooliFile(checksum, filepath, file, *count);
        (*count)++;
        // free(buffer);
      }
      free(current_path);
    }
  }

  if(0 != errno) {
    syslog(LOG_WARNING, "Error reading file/directory within %s", dir);
  }
  closedir(dirp);
}
コード例 #2
0
ファイル: juce_ZipFile.cpp プロジェクト: COx2/JUCE_JAPAN_DEMO
Result ZipFile::uncompressEntry (int index, const File& targetDirectory, bool shouldOverwriteFiles)
{
    auto* zei = entries.getUnchecked (index);

   #if JUCE_WINDOWS
    auto entryPath = zei->entry.filename;
   #else
    auto entryPath = zei->entry.filename.replaceCharacter ('\\', '/');
   #endif

    if (entryPath.isEmpty())
        return Result::ok();

    auto targetFile = targetDirectory.getChildFile (entryPath);

    if (entryPath.endsWithChar ('/') || entryPath.endsWithChar ('\\'))
        return targetFile.createDirectory(); // (entry is a directory, not a file)

    ScopedPointer<InputStream> in (createStreamForEntry (index));

    if (in == nullptr)
        return Result::fail ("Failed to open the zip file for reading");

    if (targetFile.exists())
    {
        if (! shouldOverwriteFiles)
            return Result::ok();

        if (! targetFile.deleteFile())
            return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());
    }

    if (! targetFile.getParentDirectory().createDirectory())
        return Result::fail ("Failed to create target folder: " + targetFile.getParentDirectory().getFullPathName());

    {
        FileOutputStream out (targetFile);

        if (out.failedToOpen())
            return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());

        out << *in;
    }

    targetFile.setCreationTime (zei->entry.fileTime);
    targetFile.setLastModificationTime (zei->entry.fileTime);
    targetFile.setLastAccessTime (zei->entry.fileTime);

    return Result::ok();
}
コード例 #3
0
ファイル: utilities.c プロジェクト: icewall/ForceDelete
void r0_closeAllHandles(wchar_t* filePath)
{
	MY_SYSTEM_HANDLE_INFORMATION *shiTable;
	EPROCESS *eprocess;
	unsigned long i;
	FILE_OBJECT *file;
	OBJECT_NAME_INFORMATION *objectNameInformation = 0;
	unsigned long filePathLength = wcslen(filePath);

	shiTable = enumerateHandles();
	for(i = 0; i < shiTable->NumberOfHandles;i++)
	{		
		if( isFile( shiTable->Handles[i].ObjectTypeIndex) )
		{					
			file = (FILE_OBJECT*)shiTable->Handles[i].Object;			
			if(!file || file->FileName.Length == 0)
				continue;
			
			getFullPathName(file,&objectNameInformation);

			if((objectNameInformation->Name.Length/2 ) != filePathLength)
				continue;
					
			if( !_wcsnicmp(filePath,(wchar_t*)objectNameInformation->Name.Buffer,filePathLength) )
			{
				PsLookupProcessByProcessId((HANDLE)shiTable->Handles[i].UniqueProcessId,&eprocess);
				KeAttachProcess(eprocess);//switch context to process one
				ZwClose((HANDLE)shiTable->Handles[i].HandleValue);
				KeDetachProcess();				
			}
		}
	}
	
	ExFreePoolWithTag(shiTable,0xdeadbeef);
}
コード例 #4
0
bool MainWindow::shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
                                                       StringArray& files, bool& canMoveFiles)
{
    if (auto* tv = dynamic_cast<TreeView*> (sourceDetails.sourceComponent.get()))
    {
        Array<JucerTreeViewBase*> selected;

        for (int i = tv->getNumSelectedItems(); --i >= 0;)
            if (auto* b = dynamic_cast<JucerTreeViewBase*> (tv->getSelectedItem(i)))
                selected.add (b);

        if (! selected.isEmpty())
        {
            for (int i = selected.size(); --i >= 0;)
            {
                if (auto* jtvb = selected.getUnchecked(i))
                {
                    auto f = jtvb->getDraggableFile();

                    if (f.existsAsFile())
                        files.add (f.getFullPathName());
                }
            }

            canMoveFiles = false;
            return ! files.isEmpty();
        }
    }

    return false;
}
コード例 #5
0
bool File::isOnHardDisk() const
{
    struct statfs buf;

    if (statfs (getFullPathName().toUTF8(), &buf) == 0)
    {
        switch (buf.f_type)
        {
            case U_ISOFS_SUPER_MAGIC:   // CD-ROM
            case U_MSDOS_SUPER_MAGIC:   // Probably floppy (but could be mounted FAT filesystem)
            case U_NFS_SUPER_MAGIC:     // Network NFS
            case U_SMB_SUPER_MAGIC:     // Network Samba
                return false;

            default:
                // Assume anything else is a hard-disk (but note it could
                // be a RAM disk.  There isn't a good way of determining
                // this for sure)
                return true;
        }
    }

    // Assume so if this fails for some reason
    return true;
}
コード例 #6
0
ファイル: ExpressionFunctions.cpp プロジェクト: flame1/armips
ExpressionValue expFuncRead(const std::vector<ExpressionValue>& parameters)
{
	ExpressionValue result;
	T buffer;

	if (parameters[0].isString() == false || (parameters.size() >= 2 && parameters[1].isInt() == false))
	{
		Logger::queueError(Logger::Error,L"Invalid parameter");
		return result;
	}

	std::wstring fileName = getFullPathName(parameters[0].strValue);
	u64 pos = parameters.size() >= 2 ? parameters[1].intValue : 0;

	BinaryFile file;
	if (file.open(fileName,BinaryFile::Read) == false)
	{
		Logger::queueError(Logger::Error,L"Could not open %s",fileName);
		return result;
	}

	file.setPos((long)pos);

	if (file.read(&buffer,sizeof(T)) == sizeof(T))
	{
		result.type = ExpressionValueType::Integer;
		result.intValue = (u64) buffer;
	}

	return result;
}
コード例 #7
0
bool File::isOnCDRomDrive() const
{
    struct statfs buf;

    return statfs (getFullPathName().toUTF8(), &buf) == 0
             && buf.f_type == (short) U_ISOFS_SUPER_MAGIC;
}
コード例 #8
0
void StereoCamProcessor::loadCalibration(std::string fileName) {
	std::string fullFileName = getFullPathName(fileName);

	cv::FileStorage store(fullFileName, cv::FileStorage::READ);

	cv::Mat qTemp;
	store["leftMap1"] >> leftMap1;
	store["leftMap2"] >> leftMap2;
	store["rightMap1"] >> rightMap1;
	store["rightMap2"] >> rightMap2;
	store["q"] >> qTemp;
	qTemp.convertTo(q, CV_32F);

	cv::FileNode rect =store["validPixROI1"];
	validPixROI1.x = (int) rect[0];
	validPixROI1.y = (int) rect[1];
	validPixROI1.width = (int) rect[2];
	validPixROI1.height = (int) rect[3];

	cv::FileNode rect2 =store["validPixROI2"];
	validPixROI2.x = (int) rect2[0];
	validPixROI2.y = (int) rect2[1];
	validPixROI2.width = (int) rect2[2];
	validPixROI2.height = (int) rect2[3];

	ROS_INFO("ValidPixROI1 Size: %i ", validPixROI1.area());
	ROS_INFO("ValidPixROI2 Size: %i ", validPixROI2.area());

	store.release();
}
コード例 #9
0
ExpressionValue expFuncRead(const std::wstring& funcName, const std::vector<ExpressionValue>& parameters)
{
	const std::wstring* fileName;
	u64 pos;

	GET_PARAM(parameters,0,fileName);
	GET_OPTIONAL_PARAM(parameters,1,pos,0);

	std::wstring fullName = getFullPathName(*fileName);

	BinaryFile file;
	if (file.open(fullName,BinaryFile::Read) == false)
	{
		Logger::queueError(Logger::Error,L"Could not open %s",fileName);
		return ExpressionValue();
	}

	file.setPos((long)pos);

	T buffer;
	if (file.read(&buffer,sizeof(T)) != sizeof(T))
		return ExpressionValue();

	return ExpressionValue((u64) buffer);
}
コード例 #10
0
ExpressionValue expFuncFileSize(const std::wstring& funcName, const std::vector<ExpressionValue>& parameters)
{
	const std::wstring* fileName;
	GET_PARAM(parameters,0,fileName);

	std::wstring fullName = getFullPathName(*fileName);
	return ExpressionValue(fileSize(fullName));
}
コード例 #11
0
File File::getLinkedTarget() const
{
    String f (getLinkedFile (getFullPathName()));

    if (f.isNotEmpty())
        return getSiblingFile (f);

    return *this;
}
コード例 #12
0
void PokeLaunchApplication::initialise(const String &commandLine) {
  StringArray args;
  args.addTokens(commandLine, true);

  if (args.contains("--help")) {
    std::cerr << "arguments:" << std::endl;
    std::cerr << "  --help:	Print usage help" << std::endl;
    std::cerr << "  --fakewifi:	Use fake WifiStatus" << std::endl;
    quit();
  }

  auto configFile = assetFile("config.json");
  if (!configFile.exists()) {
    std::cerr << "Missing config file: " << configFile.getFullPathName() << std::endl;
    quit();
  }

  auto configJson = JSON::parse(configFile);
  if (!configJson) {
    std::cerr << "Could not parse config file: " << configFile.getFullPathName() << std::endl;
    quit();
  }

  // open sound handle

  if(!sound())
    DBG("Sound failed to initialize");

  // Populate with dummy data
  {
    if (args.contains("--fakewifi"))
      wifiStatus = &wifiStatusJson;
    else
      wifiStatus = &wifiStatusNM;

    wifiStatus->initializeStatus();

    auto deviceListFile = assetFile("bluetooth.json");
    bluetoothStatus.populateFromJson(JSON::parse(deviceListFile));
  }

  mainWindow = new MainWindow(getApplicationName(), configJson);
}
コード例 #13
0
ファイル: CDirectiveFile.cpp プロジェクト: kabochi/armips
CDirectiveIncbin::CDirectiveIncbin(ArgumentList& args)
{
	fileName = getFullPathName(args[0].text);

	if (fileExists(fileName) == false)
	{
		Logger::printError(Logger::FatalError,L"File %s not found",fileName);
		return;
	}

	int inputFileSize = fileSize(fileName);
	if (args.size() >= 2)
	{
		// load start address
		if (ConvertExpression(args[1].text,startAddress) == false)
		{
			Logger::printError(Logger::FatalError,L"Invalid start address %s",args[1].text);
			return;
		}

		if (startAddress >= inputFileSize)
		{
			Logger::printError(Logger::Error,L"Start address 0x%08X after end of file",startAddress);
			return;
		}

		if (args.size() >= 3)
		{
			// load size too
			if (ConvertExpression(args[2].text,loadSize) == false)
			{
				Logger::printError(Logger::FatalError,L"Invalid size %s",args[1].text);
				return;
			}

			if (startAddress+loadSize > inputFileSize)
			{
				Logger::printError(Logger::Warning,L"Loading beyond file end, truncating");
				loadSize =  inputFileSize-startAddress;
			}
		} else {
			loadSize =  inputFileSize-startAddress;
		}
	} else {
		startAddress = 0;
		loadSize = inputFileSize;
	}

	g_fileManager->advanceMemory(loadSize);
}
コード例 #14
0
/*! アセットファイルの読み込みを行う
@param[in] sceneMgr
@param[in] assetFileName
@param[in] assetName
*/
Ogre::SceneNode* AssetLoader::createChildSceneNodeWithTransform(Ogre::SceneNode* scnNode, const aiNode* ainode)
{	
	Ogre::SceneNode *node = scnNode->createChildSceneNode(getFullPathName(ainode)); //std::string(ainode->mName.data)+"_Node");

	aiVector3D scl;
	aiQuaternion rot;
	aiVector3D pos;

	ainode->mTransformation.Decompose(scl, rot, pos);
	node->setOrientation(rot.w, rot.x, rot.y, rot.z);
	node->setPosition(pos.x, pos.y, pos.z);
	node->setScale(scl.x, scl.y, scl.z);

	return node;
}
コード例 #15
0
ファイル: ExpressionFunctions.cpp プロジェクト: flame1/armips
ExpressionValue expFuncFileSize(const std::vector<ExpressionValue>& parameters)
{
	ExpressionValue result;

	if (parameters[0].isString() == false)
	{
		Logger::queueError(Logger::Error,L"Invalid parameter");
		return result;
	}

	std::wstring fileName = getFullPathName(parameters[0].strValue);

	result.type = ExpressionValueType::Integer;
	result.intValue = fileSize(fileName);
	return result;
}
コード例 #16
0
ファイル: jucer_Module.cpp プロジェクト: azeteg/HISE
File EnabledModuleList::findUserModuleFolder (const String& possiblePaths, const String& moduleID)
{
    auto paths = StringArray::fromTokens (possiblePaths, ";", {});

    for (auto p : paths)
    {
        auto f = File::createFileWithoutCheckingPath (p.trim());
        if (f.exists())
        {
            auto moduleFolder = getModuleFolderFromPathIfItExists (f.getFullPathName(), moduleID, project);
            if (moduleFolder != File())
                return moduleFolder;
        }
    }

    return {};
}
コード例 #17
0
CAssemblerCommand* parseDirectiveInclude(Parser& parser, int flags)
{
    const Token& start = parser.peekToken();

    std::vector<Expression> parameters;
    if (parser.parseExpressionList(parameters,1,2) == false)
        return nullptr;

    std::wstring fileName;
    if (parameters[0].evaluateString(fileName,true) == false)
        return nullptr;

    fileName = getFullPathName(fileName);

    TextFile::Encoding encoding = TextFile::GUESS;
    if (parameters.size() == 2)
    {
        std::wstring encodingName;
        if (parameters[1].evaluateString(encodingName,true) == false
                && parameters[1].evaluateIdentifier(encodingName) == false)
            return nullptr;

        encoding = getEncodingFromString(encodingName);
    }

    // don't include the file if it's inside a false block
    if (parser.isInsideTrueBlock() == false)
        return new DummyCommand();

    if (fileExists(fileName) == false)
    {
        parser.printError(start,L"Included file \"%s\" does not exist",fileName);
        return nullptr;
    }

    TextFile f;
    if (f.open(fileName,TextFile::Read,encoding) == false)
    {
        parser.printError(start,L"Could not open included file \"%s\"",fileName);
        return nullptr;
    }

    return parser.parseFile(f);
}
コード例 #18
0
ファイル: Directives.cpp プロジェクト: Blade2187/armips
bool DirectiveInclude(ArgumentList& List, int flags)
{
	std::wstring fileName = getFullPathName(List[0].text);

	TextFile::Encoding encoding = TextFile::GUESS;
	if (List.size() == 2)
		encoding = getEncodingFromString(List[1].text);

	int FileNum = Global.FileInfo.FileNum;
	int LineNum = Global.FileInfo.LineNumber;
	if (fileExists(fileName) == false)
	{
		Logger::printError(Logger::Error,L"Included file \"%s\" does not exist",fileName.c_str());
		return false;
	}
	LoadAssemblyFile(fileName,encoding);
	Global.FileInfo.FileNum = FileNum;
	Global.FileInfo.LineNumber = LineNum;
	return true;
}
コード例 #19
0
bool File::isOnHardDisk() const
{
    struct statfs buf;

    if (statfs (getFullPathName().toUTF8(), &buf) == 0)
    {
        switch (buf.f_type)
        {
            case U_ISOFS_SUPER_MAGIC:   // CD-ROM
            case U_MSDOS_SUPER_MAGIC:   // Probably floppy (but could be mounted FAT filesystem)
            case U_NFS_SUPER_MAGIC:     // Network NFS
            case U_SMB_SUPER_MAGIC:     // Network Samba
                return false;

            default: break;
        }
    }

    // Assume so if this fails for some reason
    return true;
}
コード例 #20
0
ファイル: Directives.cpp プロジェクト: Blade2187/armips
bool DirectiveLoadTable(ArgumentList& List, int flags)
{
	std::wstring fileName = getFullPathName(List[0].text);

	if (fileExists(fileName) == false)
	{
		Logger::printError(Logger::Error,L"Table file \"%s\" does not exist",fileName.c_str());
		return false;
	}

	TextFile::Encoding encoding = TextFile::GUESS;
	if (List.size() == 2)
		encoding = getEncodingFromString(List[1].text);

	if (Global.Table.load(fileName,encoding) == false)
	{
		Logger::printError(Logger::Error,L"Invalid table file \"%s\"",fileName.c_str());
		return false;
	}
	return true;
}
コード例 #21
0
ファイル: shell.c プロジェクト: tijuo/Silverbox-OS
int doCommand( char *command, size_t comm_len, char *arg_str )
{
  if( strncmp( command, "help", 4 ) == 0 || strncmp( command, "?", 1 ) == 0 )
  {
    printf("read <path> - Read the contents of a file\n");
    printf("ld [path] - List the contents of a directory\n");
    printf("cd [path] - Change current directory\n");
    printf("wd - Display the current working directory\n");
    printf("exec <path> - Explicitly execute a file\n");
    printf("echo <msg> - Prints a message\n");
    printf("time - Displays the current time\n");
    printf("help OR ? - Prints this message\n");
  }
  else if( strncmp( command, "read", 4 ) == 0 )
  {

    int result;
    int len;
    void *file_buffer = NULL;
    char *path = getFullPathName( arg_str );
    FILE *stream = fopen(path, "r");

    if( !stream )
    {
      printf("Unable to open stream\n");
      return -1;
    }

    fseek(stream, 0, SEEK_END);
    len = ftell(stream);

    if( len < 0 )
      return 0;
    else if( len == 0 )
    {
      printf("Empty\n");
      return 0;
    }

    file_buffer = malloc( len );
    fseek(stream, 0, SEEK_SET);

    result = fread(file_buffer, 1, len, stream);

    if( !file_buffer || result < 0 )
      return -1;
    else if( len > 0 )
      printf("%.*s\n", result, file_buffer );

    free(file_buffer);
    fclose(stream);
  }
  else if( strncmp( command, "wd", 2 ) == 0 )
    printf("%.*s\n", PATH_LEN, currDir);
  else if( strncmp( command, "cd", 2 ) == 0 )
  {
    char *path;
    size_t pathLen;

    if( arg_str == NULL || strlen(arg_str) == 0 )
      path = "/";
    else if( arg_str[0] == '/' )
      path = arg_str;
    else
      path = getFullPathName( arg_str );

    if( getFileAttributes( path, attrib_list ) >= 0 )
      strncpy( currDir, path, PATH_LEN );
    else
      return -1;
  }
  else if( strncmp( command, "time", 4 ) == 0 )
  {
    time_t t = time(NULL);

    printf("The time/date is: %s", asctime(gmtime(&t)));
  }
  else if( strncmp( command, "ld", 2 ) == 0 )
  {
    int n;
    char *path, *buffer;
    size_t pathLen;

    if( arg_str == NULL || strlen(arg_str) == 0 )
      path = currDir;
    else
      path = getFullPathName(arg_str);

    n = listDir(path, sizeof attrib_list / sizeof(struct FileAttributes), attrib_list);

    if( n < 0 )
    {
      printf("Failure\n");

      return -1;
    }

    printf("Listing %d entries of %.*s:\n", n, strlen(path), path);

    if( n == 0 )
      printf("No entries\n");
    else
    {
      for(unsigned i=0; i < (unsigned)n; i++)
        printf("%.*s%c\n", attrib_list[i].name_len, attrib_list[i].name, ((attrib_list[i].flags & FS_DIR) ? '/' : '\0'));
    }
  }
  else if( strncmp( command, "echo", 4 ) == 0 )
  {
    if( arg_str )
      printf("%.*s\n", comm_len, arg_str);
  }
  else if( strncmp( command, "exec", 4 ) == 0 )
  {
    char *fName = strtok(arg_str, " "), *args="";
    printf("Executing '%s'\n", fName);
    return exec(fName, args);
  }
  else
  {
    printf("Unknown command!\n");
    return -1;
  }
  return 0;
}
コード例 #22
0
void AssetLoader::readModel(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* scnNode, const aiScene* scene, aiNode* nd)
{
	for (size_t n = 0; n < nd->mNumChildren; n++) 
	{	
		aiNode* cnd = nd->mChildren[n];
		Ogre::SceneNode* cnode = createChildSceneNodeWithTransform(scnNode, cnd);

		for (size_t i = 0; i < cnd->mNumMeshes; i++) {
			aiMesh* m = scene->mMeshes[cnd->mMeshes[i]];	
			aiMaterial* mat = scene->mMaterials[m->mMaterialIndex];

			std::string nodeName = getFullPathName(cnd);
			Ogre::MaterialPtr omat = createMaterial(Ogre::String(nodeName), m->mMaterialIndex, mat);

			aiVector3D* vec  = m->mVertices;
			aiVector3D* norm = m->mNormals;
			aiVector3D* uv   = m->mTextureCoords[0];
			aiColor4D*  vcol = NULL;	
			if (m->HasVertexColors(0)) vcol = m->mColors[0];

			// 頂点情報の読み込み
			Ogre::AxisAlignedBox aab;
			Ogre::ManualObject* mobj = new Ogre::ManualObject(nodeName+"_MObj");
			mobj->begin(omat->getName());
			//mobj->begin("Ogre/Skin");
			for (size_t n = 0; n < m->mNumVertices; n ++) {
				Ogre::Vector3 position(vec->x, vec->y, vec->z);
				aab.merge(position);

				mobj->position(vec->x, vec->y, vec->z); 
				vec++;  

				mobj->normal(norm->x, norm->y, norm->z);
				norm++; 

				if (uv)   { 
					mobj->textureCoord(uv->x, uv->y);        
					uv++;   
				}
				if (vcol) { 
					mobj->colour(vcol->r, vcol->g, vcol->b, vcol->a); 
					vcol++;
				}
			}

			// ポリゴンの構築
			for (size_t n = 0; n < m->mNumFaces; n++) {
				aiFace* face = &m->mFaces[n];
				for (size_t k = 0; k < face->mNumIndices; k++) {
					mobj->index(face->mIndices[k]);
				}
			}
			mobj->end();
			mobj->setBoundingBox(aab);

			Ogre::String meshName(nodeName+"_Mesh");
			mobj->convertToMesh(meshName);
			delete mobj;

			Ogre::String entityName(nodeName+"_Entity");
			std::cout << "entity: " << entityName << std::endl;
			Ogre::Entity* ent = sceneMgr->createEntity(entityName, meshName);
			cnode->attachObject(ent);
		}

		readModel(sceneMgr, cnode, scene, cnd);
	}
}
コード例 #23
0
bool File::isSymbolicLink() const
{
    return getLinkedFile (getFullPathName()).isNotEmpty();
}
コード例 #24
0
ファイル: MainComponent.cpp プロジェクト: Snaptags/MIDI2LR
void MainContentComponent::buttonClicked(juce::Button* button) { //-V2009 overridden method
  if (button == &rescan_button_) {
      // Re-enumerate MIDI IN and OUT devices

    if (midi_processor_) {
      midi_processor_->RescanDevices();
    }

    if (midi_sender_) {
      midi_sender_->RescanDevices();
    }
    // Send new CC parameters to MIDI Out devices
    if (const auto ptr = lr_ipc_out_.lock()) {
      ptr->sendCommand("FullRefresh 1\n");
    }
  }
  else if (button == &remove_row_button_) {
    if (command_table_.getNumRows() > 0) {
      command_table_model_.removeAllRows();
      //command_table_model_.removeRow(static_cast<size_t>(command_table_.getSelectedRow()));
      command_table_.updateContent();
    }
  }
  else if (button == &save_button_) {
    juce::File profile_directory;

    if (settings_manager_) {
      profile_directory = settings_manager_->getProfileDirectory();
    }

    if (!profile_directory.exists()) {
      profile_directory = juce::File::getCurrentWorkingDirectory();
    }

    juce::WildcardFileFilter wildcard_filter{"*.xml", juce::String::empty, "MIDI2LR profiles"};
    juce::FileBrowserComponent browser{juce::FileBrowserComponent::canSelectFiles |
      juce::FileBrowserComponent::saveMode |
      juce::FileBrowserComponent::warnAboutOverwriting, profile_directory,
      &wildcard_filter, nullptr};
    juce::FileChooserDialogBox dialog_box{"Save profile",
        "Enter filename to save profile",
        browser,
        true,
      juce::Colours::lightgrey};
    if (dialog_box.show()) {
      juce::File selected_file = browser.getSelectedFile(0).withFileExtension("xml");

      if (command_map_) {
        command_map_->toXMLDocument(selected_file);
      }
    }
  }
  else if (button == &load_button_) {
    juce::File profile_directory;

    if (settings_manager_) {
      profile_directory = settings_manager_->getProfileDirectory();
    }

    if (!profile_directory.exists()) {
      profile_directory = juce::File::getCurrentWorkingDirectory();
    }

    juce::WildcardFileFilter wildcard_filter{"*.xml", juce::String::empty, "MIDI2LR profiles"};
    juce::FileBrowserComponent browser{juce::FileBrowserComponent::canSelectFiles |
      juce::FileBrowserComponent::openMode, profile_directory,
      &wildcard_filter, nullptr};
    juce::FileChooserDialogBox dialog_box{"Open profile", "Select a profile to open",
      browser, true, juce::Colours::lightgrey};

    if (dialog_box.show()) {
      std::unique_ptr<juce::XmlElement> xml_element{juce::XmlDocument::parse(browser.getSelectedFile(0))};
      if (xml_element) {
        const auto new_profile = browser.getSelectedFile(0);
        const std::string command = "ChangedToFullPath " + new_profile.getFullPathName().toStdString() + '\n';

        if (const auto ptr = lr_ipc_out_.lock()) {
          ptr->sendCommand(command);
        }
        profile_name_label_.setText(new_profile.getFileName(),
          juce::NotificationType::dontSendNotification);
        command_table_model_.buildFromXml(xml_element.get());
        command_table_.updateContent();
        command_table_.repaint();
      }
    }
  }
  else if (button == &settings_button_) {
    juce::DialogWindow::LaunchOptions dialog_options;
    dialog_options.dialogTitle = "Settings";
    //create new object
    auto* const component = new SettingsComponent{};
    component->Init(settings_manager_);
    dialog_options.content.setOwned(component);
    dialog_options.content->setSize(400, 300);
    dialog_options.escapeKeyTriggersCloseButton = true;
    dialog_options.useNativeTitleBar = false;
    settings_dialog_.reset(dialog_options.create());
    settings_dialog_->setVisible(true);
  }
}
コード例 #25
0
File File::getLinkedTarget() const
{
    return juce_readlink (getFullPathName().toUTF8(), *this);
}
コード例 #26
0
ファイル: CDirectiveFile.cpp プロジェクト: kabochi/armips
CDirectiveFile::CDirectiveFile(Type type, ArgumentList& args)
	: type(type)
{
	file = NULL;
	
	std::wstring originalName;
	std::wstring fileName;
	int virtualAddress;

	switch (type)
	{
	case Type::Open:
		fileName = getFullPathName(args[0].text);

		if (fileExists(fileName) == false)
		{
			Logger::printError(Logger::FatalError,L"File %s not found",fileName);
			return;
		}
		if (ConvertExpression(args[1].text,virtualAddress) == false)
		{
			Logger::printError(Logger::FatalError,L"Invalid ram address %s",args[1].text);
			return;
		}

		file = new GenericAssemblerFile(fileName,virtualAddress,false);
		break;
	case Type::Create:
		fileName = getFullPathName(args[0].text);

		if (ConvertExpression(args[1].text,virtualAddress) == false)
		{
			Logger::printError(Logger::FatalError,L"Invalid ram address %s",args[1].text);
			return;
		}

		file = new GenericAssemblerFile(fileName,virtualAddress,true);
		break;
	case Type::Copy:
		originalName = getFullPathName(args[0].text);
		fileName = getFullPathName(args[1].text);

		if (fileExists(originalName) == false)
		{
			Logger::printError(Logger::FatalError,L"File %s not found",originalName);
			return;
		}
		if (ConvertExpression(args[2].text,virtualAddress) == false)
		{
			Logger::printError(Logger::FatalError,L"Invalid ram address %s",args[2].text);
			return;
		}

		file = new GenericAssemblerFile(fileName,originalName,virtualAddress);
		break;
	case Type::Close:
		return;
	}

	g_fileManager->addFile(file);
	Global.Section++;
}