PrevUpHomeNext

Haiku c++ BEntry Rename- 2024-11-13-02


BEntry Rename

BEntry Rename, Haiku c++

#include <Entry.h>
#include <iostream>

int main()
{
	BEntry file{"audio.wav"};

	std::cout << file.Name() << " exists: " << std::boolalpha << file.Exists()
		<< std::endl;
	
	// entry_ref e_ref;
	// file.GetRef(&e_ref);

	if (file.Exists())
	{
		std::cout << "Rename audio.wav to music.wav, sure? (y/n) " << std::flush;
		std::string ans;
		std::getline(std::cin, ans);
		std::cout << std::endl;
		if (ans == "y")
		{
			file.Rename("music.wav");
			std::cout << "Renamed OK." << std::endl;
		}
	}
	else
		std::cout << "not exists!" << std::endl;


	// file.Remove();

	std::cout << std::endl;
}

Build & Run

~> g++ xx.cpp -std=c++23 -lbe -o xx
~> ./xx
audio.wav exists: true
Rename audio.wav to music.wav, sure? (y/n) y
Renamed OK.

~> ./xx
audio.wav exists: false
not exists!

~> mv music.wav audio.wav
~> ./xx
audio.wav exists: true
Rename audio.wav to music.wav, sure? (y/n) n

Links

Haiku API Docs https://api.haiku-os.org

Haiku Home - Haiku OS

Back Index - Dig Haiku OS c++

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz

K


PrevUpHomeNext